From 95f7c040992097e9fd0dc3af3381e840e4da3ca7 Mon Sep 17 00:00:00 2001 From: Baoyi Chen Date: Thu, 29 Oct 2020 18:54:20 +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: Baoyi Chen --- .../websocket/common/extensions/compress/ByteAccumulator.java | 2 +- .../websocket/common/extensions/compress/CompressExtension.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 fb010085696a..efdf7741e8d8 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 @@ -55,7 +55,7 @@ public void copyChunk(ByteBuffer buffer) if (length > 0) { - chunks.add((ByteBuffer) buffer.flip()); + chunks.add((ByteBuffer)buffer.flip()); this.length += length; } else 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 47250add1f29..215c45607870 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 @@ -198,7 +198,7 @@ int copyChunk(Inflater inflater, ByteAccumulator accumulator, ByteBuffer buf) th } position += read; } - accumulator.copyChunk((ByteBuffer) buf.position(position)); + accumulator.copyChunk((ByteBuffer)buf.position(position)); return position; }