Added timeout to MC's download of sound resouces.

This commit is contained in:
LexManos 2012-08-17 13:32:20 -07:00
parent 20e38dca99
commit 21b4525643

View file

@ -0,0 +1,37 @@
--- ../src_base/minecraft/net/minecraft/src/ThreadDownloadResources.java
+++ ../src_work/minecraft/net/minecraft/src/ThreadDownloadResources.java
@@ -6,6 +6,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
+import java.net.URLConnection;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import net.minecraft.client.Minecraft;
@@ -45,7 +47,11 @@
URL var1 = new URL("http://s3.amazonaws.com/MinecraftResources/");
DocumentBuilderFactory var2 = DocumentBuilderFactory.newInstance();
DocumentBuilder var3 = var2.newDocumentBuilder();
- Document var4 = var3.parse(var1.openStream());
+ //Add a timeout of 60 seconds to getting the list, MC stalls without sound for some users.
+ URLConnection con = var1.openConnection();
+ con.setConnectTimeout(60000);
+ con.setReadTimeout(60000);
+ Document var4 = var3.parse(con.getInputStream());
NodeList var5 = var4.getElementsByTagName("Contents");
for (int var6 = 0; var6 < 2; ++var6)
@@ -169,7 +175,11 @@
private void downloadResource(URL par1URL, File par2File, long par3) throws IOException
{
byte[] var5 = new byte[4096];
- DataInputStream var6 = new DataInputStream(par1URL.openStream());
+ //Add a timeout of 60 seconds to getting the list, MC stalls without sound for some users.
+ URLConnection con = par1URL.openConnection();
+ con.setConnectTimeout(60000);
+ con.setReadTimeout(60000);
+ DataInputStream var6 = new DataInputStream(con.getInputStream());
DataOutputStream var7 = new DataOutputStream(new FileOutputStream(par2File));
boolean var8 = false;