# HG changeset patch # User sherman # Date 1539033292 25200 # Node ID 2a85adf3c330e950db0d660c69be77658c1bdfb8 # Parent 0e6e0d584b4782f1741457a8d47052d5a966ea3f 8211728: JarFile::versionedStream() does not filter META-INF resources in versioned stream Reviewed-by: alanb diff -r 0e6e0d584b47 -r 2a85adf3c330 src/java.base/share/classes/java/util/jar/JarFile.java --- a/src/java.base/share/classes/java/util/jar/JarFile.java Mon Oct 08 13:56:28 2018 -0700 +++ b/src/java.base/share/classes/java/util/jar/JarFile.java Mon Oct 08 14:14:52 2018 -0700 @@ -556,7 +556,8 @@ return JUZFA.entryNameStream(this).map(this::getBasename) .filter(Objects::nonNull) .distinct() - .map(this::getJarEntry); + .map(this::getJarEntry) + .filter(Objects::nonNull); } return stream(); } diff -r 0e6e0d584b47 -r 2a85adf3c330 test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java --- a/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java Mon Oct 08 13:56:28 2018 -0700 +++ b/test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java Mon Oct 08 14:14:52 2018 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 8163798 8189611 + * @bug 8163798 8189611 8211728 * @summary basic tests for multi-release jar versioned streams * @library /test/lib * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar @@ -82,7 +82,8 @@ "v10/p/Foo.class", "v10/q/Bar.class", "v" + LATEST_VERSION + "/p/Bar.class", - "v" + LATEST_VERSION + "/p/Foo.class" + "v" + LATEST_VERSION + "/p/Foo.class", + "v" + LATEST_VERSION + "/META-INF/Foo.class" ); jar("cf mmr.jar -C base . " + @@ -224,6 +225,11 @@ throw new UncheckedIOException(x); } }); + + if (!unversionedEntryNames.contains("META-INF/Foo.class") || + versionedNames.indexOf("META-INF/Foo.class") != -1) { + Assert.fail("versioned META-INF/Foo.class test failed"); + } } }