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

Cannot create a ZIP file containing zero entries

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 5.0
    • core-libs
    • b37
    • x86
    • windows_xp
    • Not verified

      FULL PRODUCT VERSION :
      1.5.0_07
      1.6.0-beta2-b85

      A DESCRIPTION OF THE PROBLEM :
      Using a ZipOutputStream, I cannot create a ZIP file which contains no entries. This should be allowed (see bug 6334003).

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.util.zip.ZipException: ZIP file must have at least one entry
      at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:304)
      at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:146)
      at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321)
      at Test.main(Test.java:9)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Try to create a ZIP file with no entries. This will fail with
      // the following exception: "ZIP file must have at least one entry".
      // See also bug 6334003.

      import java.io.FileOutputStream;
      import java.util.zip.ZipOutputStream;

      public class Test {

          public static void main(String[] args) {
              try {
                  ZipOutputStream zip = new ZipOutputStream(new FileOutputStream("test.zip"));
                  zip.close();
              }
              catch(Exception ex) {
                  ex.printStackTrace();
              }
          }

      }

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

            bristor Dave Bristor (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: