Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8241883

(zipfs) SeekableByteChannel:close followed by SeekableByteChannel:close will throw an NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 15
    • None
    • core-libs
    • None
    • b19

      Using this test:

          @Test(dataProvider = "zipfsMap")
          public void sbcZipCCETest(final Map<String, String> env,
                                    final int compression) throws Exception {
              Path zipFile = generatePath(HERE, "test", ".zip");
              Files.deleteIfExists(zipFile);
              Entry e0 = Entry.of("Entry-0", compression, THE_SLAMS);
              zip(zipFile, env, e0);
              // Create the ByteBuffer that will be used
              ByteBuffer bb = ByteBuffer.wrap("First Serve".getBytes(StandardCharsets.UTF_8));
              // Check that ClosedChannelException is thrown if the channel is closed
              try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, env);
                   SeekableByteChannel sbc = Files.newByteChannel(zipfs.getPath(e0.name), Set.of(READ, WRITE))) {
                  sbc.close();
              }
              Files.deleteIfExists(zipFile);
          }

      Results in:

      -------------
      java.lang.NullPointerException
      at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
      at jdk.zipfs/jdk.nio.zipfs.ByteArrayChannel.toByteArray(ByteArrayChannel.java:186)
      at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem$EntryOutputChannel.close(ZipFileSystem.java:897)
      at test.FailingChannelTests.sbcZipCCETest(FailingChannelTests.java:184)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
      at org.testng.TestRunner.privateRun(TestRunner.java:648)
      at org.testng.TestRunner.run(TestRunner.java:505)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
      at org.testng.SuiteRunner.run(SuiteRunner.java:364)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
      at org.testng.TestNG.runSuites(TestNG.java:1049)
      at org.testng.TestNG.run(TestNG.java:1017)
      at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
      at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)

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

            lancea Lance Andersen
            lancea Lance Andersen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: