changeset 1502:dfc800562a29

Fixed PR3637 - making cache work with jdk9+ #runtime jar url anchor * netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java: (retrieve) if jar is not found in cache, ale url without anchor is attempted * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: usinf localFile.toURI().toURL() instead of direct localFile.toURL()
author Jiri Vanek <jvanek@redhat.com>
date Tue, 18 Dec 2018 11:15:38 +0100
parents fd84d9b293df
children 19467a2f1f25
files ChangeLog netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Nov 23 15:33:04 2018 +0100
+++ b/ChangeLog	Tue Dec 18 11:15:38 2018 +0100
@@ -1,3 +1,10 @@
+2018-11-27  Jiri Vanek <jvanek@redhat.com>
+            Lars Herschke <lhersch@dssgmbh.de>
+
+	Fixed PR3637 - making cache work with jdk9+ #runtime jar url anchor
+	* netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java: (retrieve) if jar is not found in cache, ale url without anchor is attempted
+	* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: usinf localFile.toURI().toURL() instead of direct localFile.toURL()
+
 2018-11-23  Lars Herschke <lhersch@dssgmbh.de>
             Jiri Vanek <jvanek@redhat.com>
 
--- a/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java	Fri Nov 23 15:33:04 2018 +0100
+++ b/netx/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java	Tue Dec 18 11:15:38 2018 +0100
@@ -86,6 +86,12 @@
     @Override
     public java.util.jar.JarFile retrieve(URL url) throws IOException {
         URL localUrl = mapping.get(url);
+        if (localUrl == null) {
+            if (url.getRef() != null) {
+                url = new URL(url.toString().substring(0, url.toString().lastIndexOf(url.getRef()) - 1));
+                localUrl = mapping.get(url);
+            }
+        }
 
         if (localUrl == null) {
             /*
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Fri Nov 23 15:33:04 2018 +0100
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Tue Dec 18 11:15:38 2018 +0100
@@ -1401,7 +1401,7 @@
                         // there is currently no mechanism to cache files per
                         // instance.. so only index cached files
                         if (localFile != null) {
-                            CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), localFile.toURL());
+                            CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), localFile.toURI().toURL());
 
                             try (JarFile jarFile = new JarFile(localFile.getAbsolutePath())) {
                                 Manifest mf = jarFile.getManifest();