Snappy.compress declares to throw IOException but does not throw any. #26

tkowalcz opened this Issue Mar 22, 2013 · 2 comments


None yet

2 participants


Snappy.compress method declaration includes "throws IOException". Implementation just calls rawCompress() that does not throw IOException so this throws is not needed.

It makes sense that when operating on in memory byte array there is no place to throw IOException.


It looks like I forgot to add throws IOException statement in rawCompress.

In the native code (SnappyNative.cpp), there is a possibility that it throws IOException when an invalid object is passed to this API.


It would be a corner case, but rawCompress uses GetPrimitiveArrayCritical in JNI, and it would throw when arrays must be copied to somewhere in JVM heap but sufficient amount of memory is not available.

Oracle JDK and OpenJDK never create copies of arrays in GetPrimitiveArrayCritical, so this error never happens. The other JVM implementation might have different behavior.

@xerial xerial closed this in 64c35c7 Mar 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment