changeset in /hg/icedtea: 2008-05-07 Joshua Sumali <jsumali at re...

Joshua Sumali jsumali at redhat.com
Thu May 29 14:13:35 PDT 2008


changeset 1f85b520d105 in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=1f85b520d105
description:
	2008-05-07  Joshua Sumali  <jsumali at redhat.com>

	        * rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Close URL
	        connections nicely instead of leaving them open.

diffstat:

2 files changed, 18 insertions(+), 2 deletions(-)
ChangeLog                                          |    5 +++++
rt/net/sourceforge/jnlp/cache/ResourceTracker.java |   15 +++++++++++++--

diffs (65 lines):

diff -r 506ca3ba0559 -r 1f85b520d105 ChangeLog
--- a/ChangeLog	Tue May 06 13:11:19 2008 -0400
+++ b/ChangeLog	Wed May 07 10:42:42 2008 -0400
@@ -1,3 +1,8 @@ 2008-05-06  Joshua Sumali  <jsumali at redh
+2008-05-07  Joshua Sumali  <jsumali at redhat.com>
+
+	* rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Close URL
+	connections nicely instead of leaving them open.
+
 2008-05-06  Joshua Sumali  <jsumali at redhat.com>
 
 	* rt/net/sourceforge/jnlp/security/CertWarningPane.java: Get publisher
diff -r 506ca3ba0559 -r 1f85b520d105 rt/net/sourceforge/jnlp/cache/ResourceTracker.java
--- a/rt/net/sourceforge/jnlp/cache/ResourceTracker.java	Tue May 06 13:11:19 2008 -0400
+++ b/rt/net/sourceforge/jnlp/cache/ResourceTracker.java	Wed May 07 10:42:42 2008 -0400
@@ -600,7 +600,8 @@ public class ResourceTracker {
 
         try {
             // create out second in case in does not exist
-            InputStream in = new BufferedInputStream( resource.connection.getInputStream() );
+            URLConnection con = resource.location.openConnection();
+            InputStream in = new BufferedInputStream(con.getInputStream());
             OutputStream out = CacheUtil.getOutputStream(resource.location, resource.downloadVersion);
             byte buf[] = new byte[1024];
             int rlen;
@@ -612,6 +613,10 @@ public class ResourceTracker {
 
             in.close();
             out.close();
+
+            // explicitly close the URLConnection.
+            if (con instanceof HttpURLConnection)
+                ((HttpURLConnection)con).disconnect();
 
             resource.changeStatus(DOWNLOADING, DOWNLOADED);
             synchronized(lock) {
@@ -648,7 +653,7 @@ public class ResourceTracker {
 
             synchronized(resource) {
                 resource.localFile = localFile;
-                resource.connection = connection;
+                // resource.connection = connection;
                 resource.size = size;
                 resource.changeStatus(CONNECT|CONNECTING, CONNECTED);
 
@@ -669,6 +674,10 @@ public class ResourceTracker {
                 lock.notifyAll(); // wake up wait's to check for completion
             }
             resource.fireDownloadEvent(); // fire CONNECTED
+
+            // explicitly close the URLConnection.
+			if (connection instanceof HttpURLConnection)
+                ((HttpURLConnection)connection).disconnect();
         }
         catch (Exception ex) {
             if (JNLPRuntime.isDebug())
@@ -857,6 +866,8 @@ public class ResourceTracker {
             synchronized (lock) {
                 // check for completion 
                 for (int i=0; i < resources.length; i++) {
+                	//NetX Deadlocking may be solved by removing this 
+                	//synch block.
                     synchronized (resources[i]) {
                         if (!resources[i].isSet(DOWNLOADED | ERROR)) {
                             finished = false;



More information about the distro-pkg-dev mailing list