From 10051a62e8f403c34b76714e7c75427493d39d05 Mon Sep 17 00:00:00 2001 From: leonchen83 Date: Wed, 28 Oct 2020 17:10:23 +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: leonchen83 --- .../common/extensions/compress/CompressExtension.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 8eabd578efc0..2403d6d42e83 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,13 +209,9 @@ 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()) + if (read == 0 && LOG.isDebugEnabled()) LOG.debug("Decompress: read 0 {}", toDetail(inflater)); break; }