Less blocking in ChunkedStream (#11150)
Motivation: We should avoid blocking in the event loop as much as possible. The InputStream.read() is a blocking method, and we don't need to call it if available() returns a positive number. Modification: Bypass calling InputStream.read() if available() returns a positive number. Result: Fewer blocking calls in the event loop, in general, when ChunkedStream is used.
This commit is contained in:
parent
ad7372b112
commit
6d35db57bd
@ -84,6 +84,9 @@ public class ChunkedStream implements ChunkedInput<ByteBuf> {
|
||||
if (closed) {
|
||||
return true;
|
||||
}
|
||||
if (in.available() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int b = in.read();
|
||||
if (b < 0) {
|
||||
|
@ -156,7 +156,7 @@ public class EpollSocketChannelConfigTest {
|
||||
if (!(e.getCause() instanceof ClosedChannelException)) {
|
||||
AssertionError error = new AssertionError(
|
||||
"Expected the suppressed exception to be an instance of ClosedChannelException.");
|
||||
error.addSuppressed(e.getCause());
|
||||
error.addSuppressed(e);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user