aboutsummaryrefslogtreecommitdiff
path: root/java/org/brotli/wrapper/dec/Decoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/org/brotli/wrapper/dec/Decoder.java')
-rw-r--r--java/org/brotli/wrapper/dec/Decoder.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/java/org/brotli/wrapper/dec/Decoder.java b/java/org/brotli/wrapper/dec/Decoder.java
index 0326403..548c14d 100644
--- a/java/org/brotli/wrapper/dec/Decoder.java
+++ b/java/org/brotli/wrapper/dec/Decoder.java
@@ -15,6 +15,7 @@ import java.util.ArrayList;
* Base class for InputStream / Channel implementations.
*/
public class Decoder {
+ private static final ByteBuffer EMPTY_BUFER = ByteBuffer.allocate(0);
private final ReadableByteChannel source;
private final DecoderJNI.Wrapper decoder;
ByteBuffer buffer;
@@ -87,6 +88,11 @@ public class Decoder {
if (bytesRead == -1) {
fail("unexpected end of input");
}
+ if (bytesRead == 0) {
+ // No input data is currently available.
+ buffer = EMPTY_BUFER;
+ return 0;
+ }
decoder.push(bytesRead);
break;