From ed43b494ec82e43260f06010067ad73dea071f4d Mon Sep 17 00:00:00 2001 From: chenby Date: Wed, 28 Oct 2020 17:04:57 +0800 Subject: [PATCH] Fix issue #5499 this PR let the ByteAccumulator recyclable. after invoke ByteAccumulator.transferTo method we can invoke ByteAccumulator.recycle method to reuse byte[] via ByteAccumulator.newByteArray method Signed-off-by: chenby --- .../common/extensions/compress/CompressExtension.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 633d13815c1e..8eabd578efc0 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 @@ -209,7 +209,11 @@ protected void decompress(ByteAccumulator accumulator, ByteBuffer buf) throws Da { byte[] output = accumulator.newByteArray(DECOMPRESS_BUF_SIZE); read = inflater.inflate(output); - if (read <= 0) + if (read < 0) + { + break; + } + else if (read == 0) { if (LOG.isDebugEnabled()) LOG.debug("Decompress: read 0 {}", toDetail(inflater));