# HG changeset patch # User Omair Majid # Date 1231903678 18000 # Node ID 3b8609a88eaf4dd76619a99fdbc4fb78e0b1ce16 # Parent fe32914531b8bd4b3b7276e19792572e1ef7c87a 2009-01-13 Omair Majid * rt/net/sourceforge/jnlp/cache/ResourceTracker.java (downloadResource): Call getVersionedResourceURL to get the versioned jar. (initializeResource): Likewise. (getVersionedResourceURL): New function. Constructs a URL with a version-id as the query. diff -r fe32914531b8 -r 3b8609a88eaf ChangeLog --- a/ChangeLog Tue Jan 13 08:30:52 2009 -0500 +++ b/ChangeLog Tue Jan 13 22:27:58 2009 -0500 @@ -1,3 +1,11 @@ +2009-01-13 Omair Majid + + * rt/net/sourceforge/jnlp/cache/ResourceTracker.java + (downloadResource): Call getVersionedResourceURL to get the versioned jar. + (initializeResource): Likewise. + (getVersionedResourceURL): New function. Constructs a URL with a + version-id as the query. + 2009-01-13 Gary Benson * contrib/jck/compile-native-code.sh: Build with -m32 or -m64. diff -r fe32914531b8 -r 3b8609a88eaf rt/net/sourceforge/jnlp/cache/ResourceTracker.java --- a/rt/net/sourceforge/jnlp/cache/ResourceTracker.java Tue Jan 13 08:30:52 2009 -0500 +++ b/rt/net/sourceforge/jnlp/cache/ResourceTracker.java Tue Jan 13 22:27:58 2009 -0500 @@ -605,7 +605,7 @@ try { // create out second in case in does not exist - URLConnection con = resource.location.openConnection(); + URLConnection con = getVersionedResourceURL(resource).openConnection(); InputStream in = new BufferedInputStream(con.getInputStream()); OutputStream out = CacheUtil.getOutputStream(resource.location, resource.downloadVersion); byte buf[] = new byte[1024]; @@ -652,7 +652,7 @@ File localFile = CacheUtil.getCacheFile(resource.location, resource.downloadVersion); // connect - URLConnection connection = resource.location.openConnection(); // this won't change so should be okay unsynchronized + URLConnection connection = getVersionedResourceURL(resource).openConnection(); // this won't change so should be okay unsynchronized int size = connection.getContentLength(); boolean current = CacheUtil.isCurrent(resource.location, resource.requestVersion, connection) && resource.getUpdatePolicy() != UpdatePolicy.FORCE; @@ -696,6 +696,29 @@ } } + + + private URL getVersionedResourceURL(Resource resource) { + String actualLocation = resource.location.getProtocol() + "://" + + resource.location.getHost(); + if (resource.location.getPort() != -1) { + actualLocation += ":" + resource.location.getPort(); + } + actualLocation += resource.location.getPath(); + if (resource.requestVersion != null + && resource.requestVersion.isVersionId()) { + actualLocation += "?version-id=" + resource.requestVersion; + } + URL versionedURL; + try { + versionedURL = new URL(actualLocation); + } catch (MalformedURLException e) { + return resource.location; + } + return versionedURL; + } + + /** * Pick the next resource to download or initialize. If there * are no more resources requested then one is taken from a