-
Bug
-
Resolution: Duplicate
-
P3
-
6u43
-
linux
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
When using ZipInputStream, an exception is thrown while ZipFile.getInputStream(ZipEntry) works.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the given test code with a zip file whose entry is >4Gb.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using " new ZipInputStream " should work when " ZipFile.getInputStream(ZipEntry) " works.
ACTUAL -
An exception is thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread " main " java.util.zip.ZipException: invalid entry size (expected 4294967295 but got 1427379256 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:386)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:156)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at LargeZipEntryTest.process(LargeZipEntryTest.java:35)
at LargeZipEntryTest.main(LargeZipEntryTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
/**
* A test that shows that using {@link ZipInputStream} fails but using {@link ZipFile#getInputStream(ZipEntry)}
* works.
*/
public class LargeZipEntryTest {
public static InputStream getWorkingInputStream(File file) throws Exception {
ZipFile zipFile = new ZipFile(file);
ZipEntry zipEntry = zipFile.entries().nextElement();
return zipFile.getInputStream(zipEntry);
}
public static InputStream getBrokenInputStream(File file) throws Exception {
InputStream fis = new FileInputStream(file);
ZipInputStream zis = new ZipInputStream(fis);
zis.getNextEntry();
return zis;
}
public static void process(InputStream is) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
int count = 0;
try {
while ((line = br.readLine()) != null) {
count++;
if (count % 1000000 == 0) {
System.out.println(count + " : " + line);
}
}
}
finally {
System.out.println( " Last line read: " + count);
br.close();
}
}
public static void main(String... args) throws Exception {
File file = new File( " /path/to/zip/file/containing/large/file " );
process(getWorkingInputStream(file));
// An exception will be thrown
process(getBrokenInputStream(file));
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
When using ZipInputStream, an exception is thrown while ZipFile.getInputStream(ZipEntry) works.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the given test code with a zip file whose entry is >4Gb.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using " new ZipInputStream " should work when " ZipFile.getInputStream(ZipEntry) " works.
ACTUAL -
An exception is thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread " main " java.util.zip.ZipException: invalid entry size (expected 4294967295 but got 1427379256 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:386)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:156)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at LargeZipEntryTest.process(LargeZipEntryTest.java:35)
at LargeZipEntryTest.main(LargeZipEntryTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
/**
* A test that shows that using {@link ZipInputStream} fails but using {@link ZipFile#getInputStream(ZipEntry)}
* works.
*/
public class LargeZipEntryTest {
public static InputStream getWorkingInputStream(File file) throws Exception {
ZipFile zipFile = new ZipFile(file);
ZipEntry zipEntry = zipFile.entries().nextElement();
return zipFile.getInputStream(zipEntry);
}
public static InputStream getBrokenInputStream(File file) throws Exception {
InputStream fis = new FileInputStream(file);
ZipInputStream zis = new ZipInputStream(fis);
zis.getNextEntry();
return zis;
}
public static void process(InputStream is) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
int count = 0;
try {
while ((line = br.readLine()) != null) {
count++;
if (count % 1000000 == 0) {
System.out.println(count + " : " + line);
}
}
}
finally {
System.out.println( " Last line read: " + count);
br.close();
}
}
public static void main(String... args) throws Exception {
File file = new File( " /path/to/zip/file/containing/large/file " );
process(getWorkingInputStream(file));
// An exception will be thrown
process(getBrokenInputStream(file));
}
}
---------- END SOURCE ----------