-
Notifications
You must be signed in to change notification settings - Fork 250
Closed
Description
In Apache Spark, I've run into problems where our own code mistakenly tries to decompress an empty stream using SnappyInputStream. In this case, snappy-java produces an error like
java.io.IOException: PARSING_ERROR(2)
at org.xerial.snappy.SnappyNative.throw_error(SnappyNative.java:84)
at org.xerial.snappy.SnappyNative.uncompressedLength(Native Method)
at org.xerial.snappy.Snappy.uncompressedLength(Snappy.java:594)
at org.xerial.snappy.SnappyInputStream.readFully(SnappyInputStream.java:125)
at org.xerial.snappy.SnappyInputStream.readHeader(SnappyInputStream.java:88)
at org.xerial.snappy.SnappyInputStream.<init>(SnappyInputStream.java:58)In SnappyInputStream.readHeader, there's a check that tests whether the header is shorter than expected or doesn't match the SnappyOutputStream magic header:
// Quick test of the header
if (readBytes < header.length || header[0] != SnappyCodec.MAGIC_HEADER[0]) {
// do the default uncompression
readFully(header, readBytes);
return;
}In the case where readBytes is 0, it would be helpful if snappy-java reported an error such as new IOException("Cannot decompress empty stream") instead of falling back on the regular Snappy decompression and throwing a confusing PARSING_ERROR.
Metadata
Metadata
Assignees
Labels
No labels