RFR: 8366128: jdk/jdk/nio/zipfs/TestPosix.java::testJarFile uses wrong file

Jaikiran Pai jpai at openjdk.org
Tue Aug 26 05:33:03 UTC 2025


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.

-------------

Commit messages:
 - 8366128: jdk/jdk/nio/zipfs/TestPosix.java::testJarFile uses wrong file

Changes: https://git.openjdk.org/jdk/pull/26936/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26936&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8366128
  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/26936.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26936/head:pull/26936

PR: https://git.openjdk.org/jdk/pull/26936


More information about the nio-dev mailing list