Allocate the one byte array only when needed

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2023-12-04 10:55:57 +01:00
parent 8484a9da70
commit 5b30fee459
1 changed files with 3 additions and 1 deletions

View File

@ -31,8 +31,8 @@ import org.eclipse.jetty.util.IO;
public class ContentSourceInputStream extends InputStream
{
private final Blocker.Shared blocking = new Blocker.Shared();
private final byte[] oneByte = new byte[1];
private final Content.Source content;
private byte[] oneByte;
private Content.Chunk chunk;
public ContentSourceInputStream(Content.Source content)
@ -43,6 +43,8 @@ public class ContentSourceInputStream extends InputStream
@Override
public int read() throws IOException
{
if (oneByte == null)
oneByte = new byte[1];
int read = read(oneByte, 0, 1);
return read < 0 ? -1 : oneByte[0] & 0xFF;
}