Name: stC104175 Date: 07/07/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
ZipFileInputStreams do not maintain references to their associated zip files.
When a ZipFile object gets finalized, it frees up native file structures used
by the input stream. Here is a program that demonstrates the problem (note that
the zip file must be relatively large to exhibit this behavior):
import java.util.zip.ZipFile;
import java.io.InputStream;
import java.io.IOException;
public class ZipFileBug
{
public static void main(String[] args) throws IOException {
InputStream is = getZipStream(args);
System.gc();
is.read(); // error occurs here...
}
private static InputStream getZipStream(String[] args) throws IOException {
ZipFile zf = new ZipFile(args[0]);
return zf.getInputStream(zf.getEntry(args[1]));
}
}
the error is:
java.io.IOException: Bad file descriptor
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$700(ZipFile.java:29)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:389)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:402)
at ZipFileBug.main(ZipFileBug.java:10)
(Review ID: 105290)
======================================================================
- duplicates
-
JDK-4332173 Missing Java reference in ZipFileInputStream causes crash
-
- Resolved
-