diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulator.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulator.java index 77dc5606a91..30efd2c592c 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulator.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/ByteAccumulator.java @@ -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) { diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java index 957d4e6477a..426d3b00eed 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java @@ -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);