This discussion is archived
4 Replies Latest reply: Aug 5, 2011 5:13 AM by 875886 RSS

[Java 7] Zip file system does not handle nested zip files

875886 Newbie
Currently Being Moderated
The ZIP FileSystem which is shipped as an extension with Java7 does not support nested ZIP files. I.e., you can open the outer zip file as a FileSystem, but if you try to open an inner zip as a FileSystem, you get this exception:
java.nio.file.ProviderNotFoundException: Provider not found
     at java.nio.file.FileSystems.newFileSystem(FileSystems.java:403)
Since the ZIP FileSystem is an extension, and not a part of the core JDK, I'm posting this here (and on Xueming's blog) in the hope that it will get resolved. It doesn't seem right to report it as a JDK bug.
  • 1. Re: [Java 7] Zip file system does not handle nested zip files
    802316 Pro
    Currently Being Moderated
    AFAIK, to open a nested archive files of any type you need to extract it before opening it. This is because a ZIP file requires random access, however a compressed file can only be read from the start. The library could do all this for you, but it has to be extracted first either into memory or on disk.
  • 2. Re: [Java 7] Zip file system does not handle nested zip files
    875886 Newbie
    Currently Being Moderated
    The zip file system definitely allows zip entries to be read without extracting them first. And--based on reviewing the ZipFS source code that Oracle has included with the JDK--it doesn't appear to be silently extracting the data to a temporary file.

    It looks like this check in ZipFileSystemProvider.newFileSystem(Path path, Map<String, ?> env) is the root cause of the exception I'm seeing:
    if (path.getFileSystem() != FileSystems.getDefault()) {
       throw new UnsupportedOperationException();
    }
    But I'm not clear on why this check exists in the first place.
  • 3. Re: [Java 7] Zip file system does not handle nested zip files
    jtahlborn Expert
    Currently Being Moderated
    872883 wrote:
    The zip file system definitely allows zip entries to be read without extracting them first. And--based on reviewing the ZipFS source code that Oracle has included with the JDK--it doesn't appear to be silently extracting the data to a temporary file.
    you missed the point of what Peter Lawrey said. in order to create a ZipFS on a zip file, it must be a file in the first place (i.e. have random access). there is no way to do random access on an entry within an existing zip file, therefore in order to create a ZipFS on a nested zip file, you would first have to extract it to a file.
  • 4. Re: [Java 7] Zip file system does not handle nested zip files
    875886 Newbie
    Currently Being Moderated
    Ahh... now I'm following you.

    I'm torn on this one -- there are some use cases where it would be ideal to have the ZipFS silently extract the inner zip file to a temporary location so they can be handled, and other use cases where that could lead to big issues (like arbitrarily large amounts of time and/or disk space being consumed in the process).

    I could support it being optional behavior but I have to admit that, during the extraction process, most applications would probably want handle user-feedback and error-reporting issues in application-specific ways anyway.