ByteAccumulator transferTo expects buffer in fill mode.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-11-05 19:11:34 +11:00
parent 7bcae9968b
commit 6e9572215b
2 changed files with 4 additions and 0 deletions

View File

@ -72,6 +72,9 @@ public class ByteAccumulator implements AutoCloseable
public void transferTo(ByteBuffer buffer)
{
// For some reason this method expects the buffer in fill mode but returns a buffer in flush mode.
BufferUtil.flipToFlush(buffer, 0);
int availableSpace = BufferUtil.space(buffer);
if (availableSpace < length)
{

View File

@ -162,6 +162,7 @@ public abstract class CompressExtension extends AbstractExtension
ByteBuffer buffer = getBufferPool().acquire(accumulator.getLength(), false);
try
{
BufferUtil.clearToFill(buffer);
accumulator.transferTo(buffer);
newFrame.setPayload(buffer);
nextIncomingFrame(newFrame);