From 575973863f3b32b9de114d4c18c27cd89d4c24a3 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 16 Jun 2009 10:07:46 +0000 Subject: [PATCH] Added missing exit condition --- .../org/jboss/netty/handler/stream/ChunkedStream.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java index a5b22f5c6d..d6c4e0e62c 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java @@ -85,8 +85,8 @@ public class ChunkedStream implements ChunkedInput { return null; } - int chunkSize = Math.min(this.chunkSize, in.available()); - byte[] chunk = new byte[chunkSize]; + final int chunkSize = Math.min(this.chunkSize, in.available()); + final byte[] chunk = new byte[chunkSize]; int readBytes = 0; for (;;) { int localReadBytes = in.read(chunk, readBytes, chunkSize - readBytes); @@ -95,6 +95,10 @@ public class ChunkedStream implements ChunkedInput { } readBytes += localReadBytes; offset += localReadBytes; + + if (readBytes == chunkSize) { + break; + } } return wrappedBuffer(chunk, 0, readBytes);