8193802: NullPointerException from JarFileSystem.getVersionMap()
Reviewed-by: mchung
This commit is contained in:
parent
0b40438ae8
commit
fec9d472e3
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -109,7 +109,9 @@ class JarFileSystem extends ZipFileSystem {
|
||||
*/
|
||||
private Function<byte[],byte[]> createVersionedLinks(int version) {
|
||||
HashMap<IndexNode,byte[]> aliasMap = new HashMap<>();
|
||||
getVersionMap(version, getInode(getBytes("/META-INF/versions"))).values()
|
||||
IndexNode verdir = getInode(getBytes("/META-INF/versions"));
|
||||
if (verdir != null) {
|
||||
getVersionMap(version, verdir).values()
|
||||
.forEach(versionNode -> { // for each META-INF/versions/{n} directory
|
||||
// put all the leaf inodes, i.e. entries, into the alias map
|
||||
// possibly shadowing lower versioned entries
|
||||
@ -124,6 +126,7 @@ class JarFileSystem extends ZipFileSystem {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return path -> aliasMap.get(IndexNode.keyOf(path));
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8144355 8144062 8176709 8194070
|
||||
* @bug 8144355 8144062 8176709 8194070 8193802
|
||||
* @summary Test aliasing additions to ZipFileSystem for multi-release jar files
|
||||
* @library /lib/testlibrary/java/util/jar
|
||||
* @build Compiler JarBuilder CreateMultiReleaseTestJars
|
||||
@ -204,6 +204,21 @@ public class MultiReleaseJarTest {
|
||||
//testCustomMultiReleaseValue("true\r\n true", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiReleaseJarWithNonVersionDir() throws Exception {
|
||||
String jfname = "multi-release-non-ver.jar";
|
||||
Path jfpath = Paths.get(jfname);
|
||||
URI uri = new URI("jar", jfpath.toUri().toString() , null);
|
||||
JarBuilder jb = new JarBuilder(jfname);
|
||||
jb.addAttribute("Multi-Release", "true");
|
||||
jb.build();
|
||||
Map<String,String> env = Map.of("multi-release", "runtime");
|
||||
try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
Files.delete(jfpath);
|
||||
}
|
||||
|
||||
private static final AtomicInteger JAR_COUNT = new AtomicInteger(0);
|
||||
|
||||
private void testCustomMultiReleaseValue(String value, boolean expected)
|
||||
|
Loading…
Reference in New Issue
Block a user