Mercurial > hg > release > icedtea6-1.2
changeset 854:1f85b520d105
2008-05-07 Joshua Sumali <jsumali@redhat.com>
* rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Close URL
connections nicely instead of leaving them open.
author | Joshua Sumali <jsumali@redhat.com> |
---|---|
date | Wed, 07 May 2008 10:42:42 -0400 |
parents | 506ca3ba0559 |
children | 07c44f5d2c52 |
files | ChangeLog rt/net/sourceforge/jnlp/cache/ResourceTracker.java |
diffstat | 2 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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-07 Joshua Sumali <jsumali@redhat.com> + + * rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Close URL + connections nicely instead of leaving them open. + 2008-05-06 Joshua Sumali <jsumali@redhat.com> * rt/net/sourceforge/jnlp/security/CertWarningPane.java: Get publisher
--- 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 @@ 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; @@ -613,6 +614,10 @@ in.close(); out.close(); + // explicitly close the URLConnection. + if (con instanceof HttpURLConnection) + ((HttpURLConnection)con).disconnect(); + resource.changeStatus(DOWNLOADING, DOWNLOADED); synchronized(lock) { lock.notifyAll(); // wake up wait's to check for completion @@ -648,7 +653,7 @@ synchronized(resource) { resource.localFile = localFile; - resource.connection = connection; + // resource.connection = connection; resource.size = size; resource.changeStatus(CONNECT|CONNECTING, CONNECTED); @@ -669,6 +674,10 @@ 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 @@ 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;