Fixed issue: NETTY-234 ChunkedStream usage fails with NegativeArraySize error

* Worked around an interesting JDK issue where InputStream.available() returns a negative value
This commit is contained in:
Trustin Lee 2009-10-07 11:41:13 +00:00
parent ab2283ee98
commit 6886a8b765

View File

@ -93,7 +93,13 @@ public class ChunkedStream implements ChunkedInput {
return null;
}
final int chunkSize = Math.min(this.chunkSize, in.available());
final int availableBytes = in.available();
final int chunkSize;
if (availableBytes <= 0) {
chunkSize = this.chunkSize;
} else {
chunkSize = Math.min(this.chunkSize, in.available());
}
final byte[] chunk = new byte[chunkSize];
int readBytes = 0;
for (;;) {