From f03b2cde62016615eb9e3c4dd46741017c66eef4 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 23 Apr 2013 22:12:07 +0900 Subject: [PATCH] Fix intermittent infinite loop in AbstractOioByteChannel.doRead() - OioByteStreamChannel.doReadBytes() did not expand the capacity of the inbound buffer properly. --- .../java/io/netty/channel/oio/OioByteStreamChannel.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java b/transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java index 0e91187108..c2b252d6b8 100644 --- a/transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java +++ b/transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java @@ -84,13 +84,7 @@ public abstract class OioByteStreamChannel extends AbstractOioByteChannel { @Override protected int doReadBytes(ByteBuf buf) throws Exception { - int length = available(); - if (length < 1) { - length = 1; - } - if (length > buf.writableBytes()) { - length = buf.writableBytes(); - } + int length = Math.max(1, Math.min(available(), buf.maxWritableBytes())); return buf.writeBytes(is, length); }