Skip to content

Commit b8a4e55

Browse files
committed
Use versioned extension cache entry, if we have...
a version. Otherwise the extension JNLP will be downloaded a 2nd time and a second entry will be created: ::i=0\13::l=http://localhost/myapp/jnlp.extension/common.jnlp::a=1706698483984:: ::i=0\0::l=http://localhost/myapp/jnlp.extension/common.jnlp::v=6.2.3::a=1706698483198:: Because the cache lookup is called twice on extensions. The second time without the version so the versioned entry is not used. Instead a new entry i=0\13 without a version is created. This works fine as long as not a new version of common.jnlp::v=6.2.4 is lookuped. Then the sorting in line 246 of net/adoptopenjdk/icedteaweb/resources/cache/CacheImpl.java fails withe a NPE, because it's missing the version.
1 parent 1be00cf commit b8a4e55

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

core/src/main/java/net/adoptopenjdk/icedteaweb/jnlp/element/resource/ExtensionDesc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public URL getLocation() {
131131
*/
132132
public void resolve() throws ParseException, IOException {
133133
if (file == null) {
134-
file = new JNLPFileFactory().create(location);
134+
file = new JNLPFileFactory().create(location, version);
135135

136136
LOG.debug("Resolve: {}", file.getInformation().getTitle());
137137

core/src/main/java/net/sourceforge/jnlp/JNLPFileFactory.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ public JNLPFile create(final URL location) throws IOException, ParseException {
4949
return create(location, new ParserSettings());
5050
}
5151

52+
/**
53+
* Generate unique key from file URL
54+
* @param location
55+
*/
56+
private String createUniqueKey(final URL location) {
57+
return Calendar.getInstance().getTimeInMillis() + "-" + ((int) (Math.random() * Integer.MAX_VALUE)) + "-" + location;
58+
}
59+
60+
/**
61+
* Create a JNLPFile from a URL and parent URLm a version and checking for
62+
* updates using the specified policy.
63+
*
64+
* @param location the location of the JNLP file
65+
* @param version the version of the JNLP file
66+
* @throws IOException if an IO exception occurred
67+
* @throws ParseException if the JNLP file was invalid
68+
*/
69+
public JNLPFile create(final URL location, final VersionString version) throws IOException, ParseException {
70+
return create(location,
71+
createUniqueKey(location),
72+
version,
73+
new ParserSettings(),
74+
JNLPRuntime.getDefaultUpdatePolicy());
75+
}
76+
5277
/**
5378
* Create a JNLPFile from a URL checking for updates using the
5479
* default policy.
@@ -59,7 +84,7 @@ public JNLPFile create(final URL location) throws IOException, ParseException {
5984
* @throws ParseException if the JNLP file was invalid
6085
*/
6186
public JNLPFile create(final URL location, final ParserSettings settings) throws IOException, ParseException {
62-
final String uniqueKey = Calendar.getInstance().getTimeInMillis() + "-" + ((int) (Math.random() * Integer.MAX_VALUE)) + "-" + location;
87+
final String uniqueKey = createUniqueKey(location);
6388
return create(location, uniqueKey, null, settings, JNLPRuntime.getDefaultUpdatePolicy());
6489
}
6590

0 commit comments

Comments
 (0)