Fix #11756 empty byte array for no content in ChunkAccumulator (#11827)

Fix #11756 empty byte array for no content in ChunkAccumulator
This commit is contained in:
Greg Wilkins 2024-05-23 06:45:27 +10:00 committed by GitHub
parent 10d0898460
commit eafa7ab0d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -72,7 +72,7 @@ public class ChunkAccumulator
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)

View File

@ -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.