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

ZipException: invalid entry size during unzip of zip file size 729MB

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Linux, jdk-14.0.1,

      A DESCRIPTION OF THE PROBLEM :
      -> Issue while unzipping a zip file size of 729 MB
      -> files size after unzip comes around 8.9GB
      ->linux command unzip works fine


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      -> Compress followig size file with zip format
      2.0M MMB_v12.15.30_sdr_equip_20200415044803.xml
      5.3G MMB_v12.19.30_fdd_radio_20200415042307.xml
      838M MMB_v12.19.30_sdr_equip_20200415044817.xml
      3.2G MMB_v12.19.30_tdd_radio_20200415043921.xml


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      files should unzip
      ACTUAL -
      Unzipping to /opt/mycom/Ashish/logs/checkZip/uncompress/MMB_v12.19.30_fdd_radio_20200415042307.xml
      java.util.zip.ZipException: invalid entry size (expected 2251885780355920 but got 5266247978 bytes)
              at java.base/java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:399)
              at java.base/java.util.zip.ZipInputStream.read(ZipInputStream.java:198)
              at java.base/java.io.FilterInputStream.read(FilterInputStream.java:106)
              at ZipUnCompress.unzip(ZipUnCompress.java:47)
              at ZipUnCompress.main(ZipUnCompress.java:25)


      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileOutputStream;
      import java.io.IOException;
      import java.util.zip.ZipEntry;
      import java.util.zip.ZipInputStream;

      public class ZipUnCompress
      {

         public ZipUnCompress()
         {
            // TODO Auto-generated constructor stub
         }

         public static void main(String[] args)
         {
            String fSource = new String("/opt/mycom/Ashish/logs/checkZip/RawSample_2000/100002_bulkcm_zte_20200415045714.zip");
            String fTarget = new String("/opt/mycom/Ashish/logs/checkZip/uncompress/");
                
            unzip(fSource, fTarget);
        }

        private static void unzip(String zipFilePath, String destDir) {
            File dir = new File(destDir);
            // create output directory if it doesn't exist
            if(!dir.exists()) dir.mkdirs();
            FileInputStream fis;
            //buffer for read and write data to file
            byte[] buffer = new byte[1024];
            try {
                fis = new FileInputStream(zipFilePath);
                ZipInputStream zis = new ZipInputStream(fis);
                ZipEntry ze = zis.getNextEntry();
                while(ze != null){
                    String fileName = ze.getName();
                    File newFile = new File(destDir + File.separator + fileName);
                    System.out.println("Unzipping to "+newFile.getAbsolutePath());
                    //create directories for sub directories in zip
                    new File(newFile.getParent()).mkdirs();
                    FileOutputStream fos = new FileOutputStream(newFile);
                    int len;
                    while ((len = zis.read(buffer)) > 0) {
                    fos.write(buffer, 0, len);
                    }
                    fos.close();
                    //close this ZipEntry
                    zis.closeEntry();
                    ze = zis.getNextEntry();
                }
                //close last ZipEntry
                zis.closeEntry();
                zis.close();
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            
        }
      }


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      WA is using ZipArchiveInputStream from commons-compress lib works fine

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: