luben / zstd-jni

JNI binding for Zstd
Other
809 stars 165 forks source link

Fix bug in ZstdBufferDecompressingStream when array backing ByteBuffer is shared #264

Closed divijvaidya closed 1 year ago

divijvaidya commented 1 year ago

Motivation

The current implementation of ZstdBufferDecompressingStream fails with com.github.luben.zstd.ZstdIOException: Unknown frame descriptor when the interface is used with a ByteBuffer which is backed by an array which is shared with other ByteBuffers. This is a bug in the implementation where we assume that the ByteBuffer represents the view of the entire backing array.

Change

Change the implementation to specifically use the array represented by the bytebuffer view instead of the entire backing array.

Testing

Added a test case which fails prior to the change and passes after it.

luben commented 1 year ago

LGTM

mikemccand commented 10 months ago

What was the impact to OpenSearch users due to this bug? Would they sometimes hit this exception, under specific circumstances? Always hit it? During indexing (maybe merging, which might decompress stored fields) or searching (when also retrieving stored fields)?