Fix a buf in CompositeChannelBuffer.setBytes() where -1 is not returned

This commit is contained in:
Trustin Lee 2012-08-09 17:50:27 +09:00
parent ce4cf5e619
commit 6d5a332667

View File

@ -508,13 +508,18 @@ 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;
}
if (localReadBytes == 0) {
break;
}
if (localReadBytes < 0) {
if (readBytes == 0) {
return -1;
} else {
break;
}
}
if (localReadBytes == localLength) {
index += localLength;
length -= localLength;