From cf87c4229dabd1f9986eb54974e48a4be175ce21 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 29 Jul 2013 20:35:42 -0700 Subject: [PATCH] Added disconnects to the version check --- common/buildcraft/core/Version.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 35f75fd9..20150603 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -68,14 +68,22 @@ public class Version implements Runnable { HttpURLConnection conn = null; while (location != null && !location.isEmpty()) { URL url = new URL(location); + + if(conn != null) + conn.disconnect(); + conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)"); conn.connect(); location = conn.getHeaderField("Location"); } + + if(conn == null) + throw new NullPointerException(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + conn.disconnect(); String line = null; String mcVersion = CoreProxy.proxy.getMinecraftVersion(); @@ -122,16 +130,24 @@ public class Version implements Runnable { HttpURLConnection conn = null; while (location != null && !location.isEmpty()) { URL url = new URL(location); + + if(conn != null) + conn.disconnect(); + conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)"); conn.connect(); location = conn.getHeaderField("Location"); } - + + if(conn == null) + throw new NullPointerException(); + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + conn.disconnect(); - String line = null; + String line; ArrayList changelog = new ArrayList(); while ((line = reader.readLine()) != null) { if (line.startsWith("#")) {