RFR: JDK-8241883: (zipfs) SeekableByteChannel:close followed by SeekableByteChannel:close will throw an NPE

Lance Andersen lance.andersen at oracle.com
Tue Apr 7 16:18:29 UTC 2020


Hi all,

Please review the fix for JDK-8241883, which addresses an issue with Zip FS where multiple calls to SeekableByteChannel::close results in an NPE.

This issue was discovered while adding the additional Zip FS test coverage for FileChannel and SeekableByteChannel

Here is the diff for the patch:
——————————
$ hg diff
diff -r f4c174bf0276 src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java      Tue Apr 07 09:03:05 2020 -0400
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java      Tue Apr 07 11:38:29 2020 -0400
@@ -892,6 +892,10 @@
 
         @Override
         public void close() throws IOException {
+            // Check to see if close() has been previously called
+            if(!isOpen()) {
+                return;
+            }
             // will update the entry
             try (OutputStream os = getOutputStream(e)) {
                 os.write(toByteArray());
diff -r f4c174bf0276 test/jdk/jdk/nio/zipfs/testng/test/ChannelTests.java
--- a/test/jdk/jdk/nio/zipfs/testng/test/ChannelTests.java      Tue Apr 07 09:03:05 2020 -0400
+++ b/test/jdk/jdk/nio/zipfs/testng/test/ChannelTests.java      Tue Apr 07 11:38:29 2020 -0400
@@ -339,14 +339,12 @@
     /**
      * Validate when SeekableByteChannel::close is called more than once, that
      * no error occurs
-     * <p>
-     * Note: this is currently disabled due to bug JDK-8241883
      *
      * @param env         Zip FS properties to use when creating the Zip file
      * @param compression The compression used when writing the entries
      * @throws Exception If an error occurs
      */
-    @Test(dataProvider = "zipfsMap", enabled = false)
+    @Test(dataProvider = "zipfsMap")
     public void sbcCloseTest(final Map<String, String> env,
                              final int compression) throws Exception {
         Path zipFile = generatePath(HERE, "test", ".zip");
$

——————————————

Mach 5 tier1 - tier3 is runs without failure

Best,
Lance
 <http://oracle.com/us/design/oracle-email-sig-198324.gif>
 <http://oracle.com/us/design/oracle-email-sig-198324.gif> <http://oracle.com/us/design/oracle-email-sig-198324.gif>
 <http://oracle.com/us/design/oracle-email-sig-198324.gif>Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering 
1 Network Drive 
Burlington, MA 01803
Lance.Andersen at oracle.com <mailto:Lance.Andersen at oracle.com>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200407/76d36843/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oracle_sig_logo.gif
Type: image/gif
Size: 658 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200407/76d36843/oracle_sig_logo.gif>


More information about the nio-dev mailing list