Skip to content

Commit f9a9938

Browse files
committed
OWS-612 : fix jars downloaded multiple times while app is running
1 parent cb751bb commit f9a9938

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

core/src/main/java/net/sourceforge/jnlp/runtime/CachedJarFileCallback.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,29 @@ public synchronized static CachedJarFileCallback getInstance() {
7373
}
7474

7575
/* our managed cache */
76-
private final Map<URL, URL> mapping;
76+
private final Map<String, URL> mapping;
7777

7878
private CachedJarFileCallback() {
79-
mapping = new ConcurrentHashMap<URL, URL>();
79+
mapping = new ConcurrentHashMap<String, URL>();
8080
}
8181

8282
public void addMapping(URL remoteUrl, URL localUrl) {
83-
mapping.put(remoteUrl, localUrl);
83+
LOG.debug("CachedJarFileCallback.addMapping : {} -> {} ", remoteUrl, localUrl);
84+
mapping.put(remoteUrl.toString(), localUrl);
8485
}
8586

8687
@Override
8788
public java.util.jar.JarFile retrieve(URL url) throws IOException {
88-
URL localUrl = mapping.get(url);
89+
URL localUrl = mapping.get(url.toString());
8990
if (localUrl == null) {
9091
if (url.getRef() != null) {
9192
url = new URL(url.toString().substring(0, url.toString().lastIndexOf(url.getRef()) - 1));
92-
localUrl = mapping.get(url);
93+
localUrl = mapping.get(url.toString());
9394
}
9495
}
9596

9697
if (localUrl == null) {
97-
LOG.info("could not find mapping for {} - falling back to downloading without caching", url);
98+
LOG.info("CachedJarFileCallback.retrieve : could not find mapping for {} - falling back to downloading without caching", url);
9899
/*
99100
* If the jar url is not known, treat it as it would be treated in
100101
* general by URLJarFile.
@@ -112,7 +113,7 @@ public java.util.jar.JarFile retrieve(URL url) throws IOException {
112113
// 2) For the plug-in, we want to cache files from class-path so we do it manually
113114
returnFile.getManifest().getMainAttributes().putValue(Attributes.Name.CLASS_PATH.toString(), "");
114115

115-
LOG.debug("Class-Path attribute cleared for {}", returnFile.getName());
116+
LOG.debug("Class-Path attribute cleared for Cached Jar {}", returnFile.getName());
116117

117118
} catch (NullPointerException npe) {
118119
// Discard NPE here. Maybe there was no manifest, maybe there were no attributes, etc.

0 commit comments

Comments
 (0)