Skip to content

Commit

Permalink
fix incomplete implementation of decompression with NIO ByteBuffers (#96
Browse files Browse the repository at this point in the history
)
  • Loading branch information
beppo-sturmtief authored Apr 9, 2023
1 parent 04dd997 commit 07071f8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public final class Decoders {
/**
* Decodes the given data buffer.
*
* @param compressed {@link ByteBuffer} source
* @param decompressed {@link ByteBuffer} destination
* @return {@link DirectDecompress} instance
* @throws IOException Thrown in case of error during encoding
* @param compressed {@link ByteBuffer} source - will be read in full (position == limit after this call).
* @param decompressed {@link ByteBuffer} destination - compressed data will be filled in beginning at position, up to remaining bytes; position is updated
* @return {@link DirectDecompress} instance - upon return, only the status code is still valid
* @throws IOException Thrown in case of error during decoding
*/
@Local
public static DirectDecompress decompress(ByteBuffer compressed, ByteBuffer decompressed) throws IOException {
Expand All @@ -47,8 +47,9 @@ public static DirectDecompress decompress(ByteBuffer compressed, ByteBuffer deco

try {
src.writeBytes(compressed);
dst.writeBytes(decompressed);
return decompress(src, dst);
final DirectDecompress result = decompress(src, dst);
dst.readBytes(decompressed);
return result;
} finally {
src.release();
dst.release();
Expand Down

0 comments on commit 07071f8

Please sign in to comment.