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

Read from input stream throws exception if ZipFile closed

XMLWordPrintable

    • sparc
    • solaris_8

      The following code opens two references to a zip file, closes one, and then attempts to read from an entry in the file:

      import java.util.zip.*;
      import java.util.jar.*;
      import java.util.*;
      import java.io.*;

      public class ZipTest {

          public static void main(String[] args) throws Exception {
              InputStream is = null;
              ZipFile zf = new ZipFile(args[0]);
              ZipFile zf2 = new ZipFile(args[0]);
              ZipEntry ze = zf.getEntry(args[1]);
              if (ze == null)
                  System.out.println("Cant find ze");
              is = zf.getInputStream(ze);
              zf.close();
              byte[] buf = new byte[128];
              is.read(buf);
          }
      }

      This code works in 1.4.0 and all previous releases. The read() method throws a ZipException("ZipFile closed.") in 1.4.1 build 08 and later releases. Customer code expects that as long as a single reference to the zip file remains open, the existing input streams should be read.

      This bug prevents BEA Weblogic from running on 1.4.1.

            kkladkosunw Konstantin Kladko (Inactive)
            soaks Scott Oaks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: