RFR: 8366128: jdk/jdk/nio/zipfs/TestPosix.java::testJarFile uses wrong file
Jaikiran Pai
jpai at openjdk.org
Tue Aug 26 11:51:34 UTC 2025
On Tue, 26 Aug 2025 05:25:10 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review of this test-only change which fixes a typo in a test method?
>
> The `test/jdk/jdk/nio/zipfs/TestPosix.java` test was introduced in Java 14 in https://bugs.openjdk.org/browse/JDK-8213031. This test has several test methods. One of those is the `testJarFile()` which first creates a JAR file `JAR_FILE` and then uses a `JarFile` instance to open that JAR file. There's however a typo in that code which causes the test method to use `JarFile` to open an unrelated `ZIP_FILE`. The reason why this test passes is because there's another test method in that test which previously has created the `ZIP_FILE` and thus the `JarFile` is able to open and parse that file.
>
> A failure of this `testJarFile()` test method can be reproduced by changing the order of these test methods to enusre that this test method is run before the others. Doing so results in the following exception:
>
>
> STARTED TestPosix::testJarFile 'testJarFile()'
> java.nio.file.NoSuchFileException: testPosix.zip
> at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
> at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
> at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
> at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:57)
> at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:162)
> at java.base/java.nio.file.Files.readAttributes(Files.java:1702)
> at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1505)
> at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:705)
> at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:204)
> at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:150)
> at java.base/java.util.jar.JarFile.<init>(JarFile.java:336)
> at java.base/java.util.jar.JarFile.<init>(JarFile.java:309)
> at java.base/java.util.jar.JarFile.<init>(JarFile.java:279)
> at TestPosix.testJarFile(TestPosix.java:764)
> at java.base/java.lang.reflect.Method.invoke(Method.java:565)
> at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
> at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
> FAILED TestPosix::testJarFile 'testJarFile()' [32ms]
>
>
> The commit in this PR fixes that typo.
Thank you Alan for the review. I verified that the test passes in our CI with this change. Since this is a trivial one liner typo fix in a test, I'll go ahead and integrate this now.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26936#issuecomment-3223850602
More information about the nio-dev
mailing list