Fix an infinite loop in CompositeChannelBuffer.setBytes()

.. which occurs when a channel is closed during I/O
This commit is contained in:
Trustin Lee 2012-07-23 15:33:14 +09:00
parent c059d13108
commit cb2b2830b2

View File

@ -508,6 +508,13 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
int localLength = Math.min(length, s.capacity() - (index - adjustment));
int localReadBytes = s.setBytes(index - adjustment, in, localLength);
if (localReadBytes <= 0) {
if (readBytes == 0) {
readBytes = localReadBytes;
}
break;
}
if (localReadBytes == localLength) {
index += localLength;
length -= localLength;