From 734351f7ef1cc6dac4a2e13f3d06f830e931fa92 Mon Sep 17 00:00:00 2001 From: gregw Date: Wed, 22 May 2024 09:41:07 +1000 Subject: [PATCH] Fix #11756 empty byte array for no content in ChunkAccumulator Fix #11756 empty byte array for no content in ChunkAccumulator --- .../src/main/java/org/eclipse/jetty/io/ChunkAccumulator.java | 2 +- .../src/main/java/org/eclipse/jetty/util/BufferUtil.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ChunkAccumulator.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ChunkAccumulator.java index 0358f8583969..c0c37eb34111 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ChunkAccumulator.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ChunkAccumulator.java @@ -72,7 +72,7 @@ public int length() public byte[] take() { if (_length == 0) - return BufferUtil.EMPTY_BUFFER.array(); + return BufferUtil.EMPTY_BYTES; byte[] bytes = new byte[_length]; int offset = 0; for (Chunk chunk : _chunks) diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java index 3d771910596d..82d39988bcd4 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java @@ -106,7 +106,8 @@ public class BufferUtil (byte)'E', (byte)'F' }; - public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(new byte[0]).asReadOnlyBuffer(); + public static final byte[] EMPTY_BYTES = new byte[0]; + public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(EMPTY_BYTES).asReadOnlyBuffer(); /** * Allocate ByteBuffer in flush mode.