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

Unzipping Dropbox Files: Only DEFLATED entries can have EXT descriptor

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11

      A DESCRIPTION OF THE PROBLEM :
      When a zip file from dropbox is read/extracted using java.util.zip.ZipInputStream, you get the following exception:

      ```
      java.util.zip.ZipException: only DEFLATED entries can have EXT descriptor
              at java.base/java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:529)
              at java.base/java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:153)
              at my.namespace.JavaZipper.unzipFile(JavaZipper.java:111)
      ```

      Here is a simple reproducer:
      ```
      @Test
      public static void TestUnzip() throws FileNotFoundException, IOException {
          var inputZipFile = new File("C:\\my\\path\\src\\file.zip");
          var outputPathStr = "C:\\my\\path\\dest";

          try(ZipInputStream zipStreamIn = new ZipInputStream(new FileInputStream(inputZipFile))) {
              ZipEntry zipEntry = null;
              
              while((zipEntry = zipStreamIn.getNextEntry()) != null) {
                  final String entryName = zipEntry.getName().replace("/", "\\"); // normalise path (windows-format)
                  
                  // ignore directories
                  if(zipEntry.isDirectory())
                      continue;
                  
                  // prepare destination path
                  File targetFile = new File( outputPathStr + "\\" + entryName );
                  targetFile.getParentFile().mkdirs();
                  
                  // zip stream to file
                  System.out.println("Extract File: " + entryName);
                  try(var zipStreamOut = new FileOutputStream(targetFile)) {
                      zipStreamIn.transferTo(zipStreamOut);
                  }
              }
          }
      }
      ```

      All commonly used zipper tools are able to extract such files (with EXT descriptor), hence it would be very useful if the Java Runtime could do the same.


            eirbjo Eirik Bjørsnøs
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: