Skip to content

Commit 44a332e

Browse files
authored
Enhance the MultiReadHttpServletRequest stream
1 parent ec13d4e commit 44a332e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

gateway-ha/src/main/java/io/trino/gateway/proxyserver/MultiReadHttpServletRequest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ public ServletInputStream getInputStream()
4545
@Override
4646
public boolean isFinished()
4747
{
48-
return byteArrayInputStream.available() > 0;
48+
// Determine if data is available for reading.
49+
return byteArrayInputStream.available() <= 0;
4950
}
5051

5152
@Override
5253
public boolean isReady()
5354
{
54-
return false;
55+
// It's an in memory stream, so it's ready to be read
56+
return true;
5557
}
5658

5759
@Override
@@ -63,6 +65,21 @@ public int read()
6365
{
6466
return byteArrayInputStream.read();
6567
}
68+
69+
// Add multibyte read versions for efficiency
70+
@Override
71+
public int read(byte[] b, int off, int len)
72+
throws IOException
73+
{
74+
return byteArrayInputStream.read(b, off, len);
75+
}
76+
77+
@Override
78+
public int read(byte[] b)
79+
throws IOException
80+
{
81+
return byteArrayInputStream.read(b);
82+
}
6683
};
6784
}
6885

0 commit comments

Comments
 (0)