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

The ZipOutputStream.finish() method changed without corresponding modification in jdk7 doc

XMLWordPrintable

      In JDK6 (6u14 b03 promotion for example), ZipOutputStream.finish() will throw a ZipException if no ZipEntry has been added. However, this is not the case in JDK7 (7 b52 promotion for example). And there's is no doc change for this behaviour change.

      The following are tese code, along with output for 6u14 b03 promotion bundle and 7 b52 promotion bundle, respectively.

      =======Begin of the code=============
      import java.util.zip.*;

      public class CloseTest_ZipOutputStream{
          public static void main(String args[]) throws Exception {
              ZipOutputStream zos = new ZipOutputStream(System.out);
              zos.close();
        }
      }
      =====End of the Code=========

      // Output for JDK6u14 b03 promotion bundle
      Exception in thread "main" java.util.zip.ZipException: ZIP file must have at least one entry
          at java.util.zip.ZipOutputStream.finish(Unknown Source)
          at java.util.zip.DeflaterOutputStream.close(Unknown Source)
          at java.util.zip.ZipOutputStream.close(Unknown Source)
          at CloseTest_ZipOutputStream.main(CloseTest_ZipOutputStream.java:7)

      // Output for jdk7 b52 promotion bundle (XXX are some unrecognizable characters)
      PKXXXXXXXXXXXXXXXXXXXX

            sherman Xueming Shen
            tonyli Tony Li (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: