Lz4FrameEncoder incorrect usage of internalNioBuffer
Motivation: Lz4FrameEncoder uses internalNioBuffer but always passes in a value of 0 for the index. This should be readerIndex(). Modifications: - change 0 to readerIndex() Result: More correct usage of internalNioBuffer in Lz4FrameEncoder.
This commit is contained in:
parent
1f6782894a
commit
675980c7ff
@ -261,7 +261,7 @@ public class Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf> {
|
|||||||
ByteBuffer outNioBuffer = out.internalNioBuffer(idx + HEADER_LENGTH, out.writableBytes() - HEADER_LENGTH);
|
ByteBuffer outNioBuffer = out.internalNioBuffer(idx + HEADER_LENGTH, out.writableBytes() - HEADER_LENGTH);
|
||||||
int pos = outNioBuffer.position();
|
int pos = outNioBuffer.position();
|
||||||
// We always want to start at position 0 as we take care of reusing the buffer in the encode(...) loop.
|
// We always want to start at position 0 as we take care of reusing the buffer in the encode(...) loop.
|
||||||
compressor.compress(buffer.internalNioBuffer(0, flushableBytes), outNioBuffer);
|
compressor.compress(buffer.internalNioBuffer(buffer.readerIndex(), flushableBytes), outNioBuffer);
|
||||||
compressedLength = outNioBuffer.position() - pos;
|
compressedLength = outNioBuffer.position() - pos;
|
||||||
} catch (LZ4Exception e) {
|
} catch (LZ4Exception e) {
|
||||||
throw new CompressionException(e);
|
throw new CompressionException(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user