#10226 fix GZIPContentDecoder buffer leak of zero-capacity buffers

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2023-08-22 11:23:42 +02:00
parent 7083fa3927
commit 2fcccef0c4
2 changed files with 8 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
/**
* <p>Returns a non-retainable {@code RetainableByteBuffer} that wraps
* the given {@code ByteBuffer}.</p>