aboutsummaryrefslogtreecommitdiff
path: root/java/org/brotli/wrapper/enc/EncoderJNI.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/org/brotli/wrapper/enc/EncoderJNI.java')
-rw-r--r--java/org/brotli/wrapper/enc/EncoderJNI.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/java/org/brotli/wrapper/enc/EncoderJNI.java b/java/org/brotli/wrapper/enc/EncoderJNI.java
index 6627f5a..5013629 100644
--- a/java/org/brotli/wrapper/enc/EncoderJNI.java
+++ b/java/org/brotli/wrapper/enc/EncoderJNI.java
@@ -27,9 +27,13 @@ class EncoderJNI {
static class Wrapper {
protected final long[] context = new long[5];
private final ByteBuffer inputBuffer;
+ private boolean fresh = true;
Wrapper(int inputBufferSize, int quality, int lgwin)
throws IOException {
+ if (inputBufferSize <= 0) {
+ throw new IOException("buffer size must be positive");
+ }
this.context[1] = inputBufferSize;
this.context[2] = quality;
this.context[3] = lgwin;
@@ -56,6 +60,7 @@ class EncoderJNI {
throw new IllegalStateException("pushing input to encoder over previous input");
}
context[1] = op.ordinal();
+ fresh = false;
nativePush(context, length);
}
@@ -86,6 +91,7 @@ class EncoderJNI {
if (!isSuccess() || !hasMoreOutput()) {
throw new IllegalStateException("pulling while data is not ready");
}
+ fresh = false;
return nativePull(context);
}