Fix intermittent infinite loop in AbstractOioByteChannel.doRead()
- OioByteStreamChannel.doReadBytes() did not expand the capacity of the inbound buffer properly.
This commit is contained in:
parent
32fa4c07f3
commit
f03b2cde62
@ -84,13 +84,7 @@ public abstract class OioByteStreamChannel extends AbstractOioByteChannel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int doReadBytes(ByteBuf buf) throws Exception {
|
protected int doReadBytes(ByteBuf buf) throws Exception {
|
||||||
int length = available();
|
int length = Math.max(1, Math.min(available(), buf.maxWritableBytes()));
|
||||||
if (length < 1) {
|
|
||||||
length = 1;
|
|
||||||
}
|
|
||||||
if (length > buf.writableBytes()) {
|
|
||||||
length = buf.writableBytes();
|
|
||||||
}
|
|
||||||
return buf.writeBytes(is, length);
|
return buf.writeBytes(is, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user