diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java index a03b8f7430c..45c41eda497 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java @@ -422,6 +422,9 @@ public class GZIPContentDecoder implements Destroyable */ public RetainableByteBuffer acquire(int capacity) { + // Zero-capacity buffers aren't released, they MUST NOT come from the pool. + if (capacity == 0) + return RetainableByteBuffer.EMPTY; return _pool.acquire(capacity, false); } } diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java index f59a7e6bdda..e1098d5191d 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java @@ -36,6 +36,11 @@ import org.eclipse.jetty.util.BufferUtil; */ public interface RetainableByteBuffer extends Retainable { + /** + * A Zero-capacity, non-retainable {@code RetainableByteBuffer}. + */ + public static RetainableByteBuffer EMPTY = wrap(BufferUtil.EMPTY_BUFFER); + /** *
Returns a non-retainable {@code RetainableByteBuffer} that wraps * the given {@code ByteBuffer}.