Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.util.zip.ZipException: invalid block type under JDK1.4.2

843811May 31 2005
I hat a long fight until I got that one:
// java.util.zip.ZipException: invalid block type
// at
// java.util.zip.InflaterInputStream.read(InflaterInputStream.java:140)
// at
// java.util.zip.GZIPInputStream.read(GZIPInputStream.java:87)
// at
// java.util.zip.InflaterInputStream.read(InflaterInputStream.java:105)
...

The reason was that the GZIPInputStream constructor consumes about 10 bytes.
If you do a reset before the first read, under 1.4.2 those 10 bytes will be read again - under jdk1.5.0, it is fortunately no longer possible to do such a reset.

So, that's my fix:
InputStream in = new GZIPInputStream(isFromDb)
...
//the next method applies not just for GZIPInputStream but any InputStream
boolean markSupported = in.markSupported();
if (markSupported) {
if (in instanceof GZIPInputStream) {
String vmVersion = System.getProperty("java.vm.version");
if (!vmVersion.startsWith("1.5")) {
markSupported = false;
log.debug("don't believe markSupported() if it is jdk1.4.2"; }
}
}
if (markSupported) {
in.reset()
}

I would be interested to hear if other people run into the same issue and whether they solved it differently!
https://www.privasphere.com/e.do?email=hauser@acm.org
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 28 2005
Added on May 31 2005
0 comments
2,618 views