Fix intermittent infinite loop in AbstractOioByteChannel.doRead()

- OioByteStreamChannel.doReadBytes() did not expand the capacity of the inbound buffer properly.
This commit is contained in:
Trustin Lee 2013-04-23 22:12:07 +09:00
parent 32fa4c07f3
commit f03b2cde62

View File

@ -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);
} }