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:
Scott Mitchell 2017-03-02 10:28:52 -08:00
parent 1f6782894a
commit 675980c7ff

View File

@ -261,7 +261,7 @@ public class Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf> {
ByteBuffer outNioBuffer = out.internalNioBuffer(idx + HEADER_LENGTH, out.writableBytes() - HEADER_LENGTH);
int pos = outNioBuffer.position();
// 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;
} catch (LZ4Exception e) {
throw new CompressionException(e);