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

NullPointerException attempting to open a ZIP filesystem with null ClassLoader

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      This will potentially occur in any OS for code that was compiled against the older API.

      A DESCRIPTION OF THE PROBLEM :
      Previously it was possible to call java.nio.file.FileSystems.newFileSystem(Path path, ClassLoader loader) with the path to a ZIP file and a null ClassLoader argument, and it would work fine. JDK 13 introduced an overloaded method, which takes a Path and a Map. Unfortunately, the code which previously worked is now calling this new overload instead, and crashing with a NullPointerException when it tries to work with the null Map.

      REGRESSION : Last worked in version 11.0.5

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create or find a ZIP file.

      call java.nio.file.FileSystems.newFileSystem(new File("/path/of/file.zip").toPath(), null); under JDK 11 or earlier; it will work fine. Try it under JDK 13 and it crashes.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An opened ZIP filesystem.
      ACTUAL -
      java.lang.NullPointerException:
                                            java.nio.file.FileSystems.newFileSystem FileSystems.java: 436
                                            java.nio.file.FileSystems.newFileSystem FileSystems.java: 524
                                  jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem ZipFileSystemProvider.java: 136

      CUSTOMER SUBMITTED WORKAROUND :
      Finding and passing a non-null ClassLoader is a workaround that is backwards compatible with earlier JDKs, but this issue has already caused problems for my users, and will likely impact other projects using ZIP filesystems. Enhancing the new overload of the method to treat a null Map the same as an empty one would restore backwards compatibility with earlier releases.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              tongwan Andrew Wang
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: