diff options
Diffstat (limited to 'java/org/brotli/wrapper')
-rw-r--r-- | java/org/brotli/wrapper/common/BUILD | 4 | ||||
-rw-r--r-- | java/org/brotli/wrapper/dec/BUILD | 6 | ||||
-rw-r--r-- | java/org/brotli/wrapper/dec/BrotliInputStream.java | 4 | ||||
-rw-r--r-- | java/org/brotli/wrapper/dec/Decoder.java | 4 | ||||
-rw-r--r-- | java/org/brotli/wrapper/dec/DecoderJNI.java | 3 | ||||
-rwxr-xr-x | java/org/brotli/wrapper/dec/EagerStreamTest.java | 2 | ||||
-rw-r--r-- | java/org/brotli/wrapper/enc/BUILD | 6 | ||||
-rw-r--r-- | java/org/brotli/wrapper/enc/EncoderJNI.java | 6 |
8 files changed, 22 insertions, 13 deletions
diff --git a/java/org/brotli/wrapper/common/BUILD b/java/org/brotli/wrapper/common/BUILD index 48b02f3..4f7ed84 100644 --- a/java/org/brotli/wrapper/common/BUILD +++ b/java/org/brotli/wrapper/common/BUILD @@ -35,7 +35,6 @@ java_library( java_test( name = "SetZeroDictionaryTest", - test_class = "org.brotli.wrapper.common.SetZeroDictionaryTest", size = "small", data = [ ":brotli_jni_no_dictionary_data", # Bazel JNI workaround @@ -43,12 +42,12 @@ java_test( jvm_flags = [ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)", ], + test_class = "org.brotli.wrapper.common.SetZeroDictionaryTest", runtime_deps = [":test_lib"], ) java_test( name = "SetRfcDictionaryTest", - test_class = "org.brotli.wrapper.common.SetRfcDictionaryTest", size = "small", data = [ ":brotli_jni_no_dictionary_data", # Bazel JNI workaround @@ -56,5 +55,6 @@ java_test( jvm_flags = [ "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)", ], + test_class = "org.brotli.wrapper.common.SetRfcDictionaryTest", runtime_deps = [":test_lib"], ) diff --git a/java/org/brotli/wrapper/dec/BUILD b/java/org/brotli/wrapper/dec/BUILD index fcf0dbf..754541a 100644 --- a/java/org/brotli/wrapper/dec/BUILD +++ b/java/org/brotli/wrapper/dec/BUILD @@ -39,7 +39,6 @@ filegroup( java_test( name = "BrotliDecoderChannelTest", - test_class = "org.brotli.wrapper.dec.BrotliDecoderChannelTest", size = "large", data = [ ":brotli_jni", # Bazel JNI workaround @@ -49,12 +48,12 @@ java_test( "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", "-DTEST_BUNDLE=$(location :test_bundle)", ], + test_class = "org.brotli.wrapper.dec.BrotliDecoderChannelTest", runtime_deps = [":test_lib"], ) java_test( name = "BrotliInputStreamTest", - test_class = "org.brotli.wrapper.dec.BrotliInputStreamTest", size = "large", data = [ ":brotli_jni", # Bazel JNI workaround @@ -64,12 +63,12 @@ java_test( "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", "-DTEST_BUNDLE=$(location :test_bundle)", ], + test_class = "org.brotli.wrapper.dec.BrotliInputStreamTest", runtime_deps = [":test_lib"], ) java_test( name = "DecoderTest", - test_class = "org.brotli.wrapper.dec.DecoderTest", size = "large", data = [ ":brotli_jni", # Bazel JNI workaround @@ -79,5 +78,6 @@ java_test( "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", "-DTEST_BUNDLE=$(location :test_bundle)", ], + test_class = "org.brotli.wrapper.dec.DecoderTest", runtime_deps = [":test_lib"], ) diff --git a/java/org/brotli/wrapper/dec/BrotliInputStream.java b/java/org/brotli/wrapper/dec/BrotliInputStream.java index 26f7a82..6e2e6e5 100644 --- a/java/org/brotli/wrapper/dec/BrotliInputStream.java +++ b/java/org/brotli/wrapper/dec/BrotliInputStream.java @@ -34,8 +34,8 @@ public class BrotliInputStream extends InputStream { this(source, DEFAULT_BUFFER_SIZE); } - public void setEager(boolean eager) { - decoder.setEager(eager); + public void enableEagerOutput() { + decoder.enableEagerOutput(); } @Override diff --git a/java/org/brotli/wrapper/dec/Decoder.java b/java/org/brotli/wrapper/dec/Decoder.java index ae4d817..26183ab 100644 --- a/java/org/brotli/wrapper/dec/Decoder.java +++ b/java/org/brotli/wrapper/dec/Decoder.java @@ -50,8 +50,8 @@ public class Decoder { throw new IOException(message); } - public void setEager(boolean eager) { - this.eager = eager; + public void enableEagerOutput() { + this.eager = true; } /** diff --git a/java/org/brotli/wrapper/dec/DecoderJNI.java b/java/org/brotli/wrapper/dec/DecoderJNI.java index 320705c..2319b1e 100644 --- a/java/org/brotli/wrapper/dec/DecoderJNI.java +++ b/java/org/brotli/wrapper/dec/DecoderJNI.java @@ -30,6 +30,7 @@ public class DecoderJNI { private final long[] context = new long[3]; private final ByteBuffer inputBuffer; private Status lastStatus = Status.NEEDS_MORE_INPUT; + private boolean fresh = true; public Wrapper(int inputBufferSize) throws IOException { this.context[1] = inputBufferSize; @@ -52,6 +53,7 @@ public class DecoderJNI { if (lastStatus == Status.OK && length != 0) { throw new IllegalStateException("pushing input to decoder in OK state"); } + fresh = false; nativePush(context, length); parseStatus(); } @@ -90,6 +92,7 @@ public class DecoderJNI { if (lastStatus != Status.NEEDS_MORE_OUTPUT && !hasOutput()) { throw new IllegalStateException("pulling output from decoder in " + lastStatus + " state"); } + fresh = false; ByteBuffer result = nativePull(context); parseStatus(); return result; diff --git a/java/org/brotli/wrapper/dec/EagerStreamTest.java b/java/org/brotli/wrapper/dec/EagerStreamTest.java index 9166092..919f6e3 100755 --- a/java/org/brotli/wrapper/dec/EagerStreamTest.java +++ b/java/org/brotli/wrapper/dec/EagerStreamTest.java @@ -56,7 +56,7 @@ public class EagerStreamTest extends BrotliJniTestBase { } }; BrotliInputStream reader = new BrotliInputStream(source); - reader.setEager(true); + reader.enableEagerOutput(); int count = 0; while (true) { log.append("^").append(count); diff --git a/java/org/brotli/wrapper/enc/BUILD b/java/org/brotli/wrapper/enc/BUILD index 42ad23e..b3d10b9 100644 --- a/java/org/brotli/wrapper/enc/BUILD +++ b/java/org/brotli/wrapper/enc/BUILD @@ -40,7 +40,6 @@ filegroup( java_test( name = "BrotliEncoderChannelTest", - test_class = "org.brotli.wrapper.enc.BrotliEncoderChannelTest", size = "large", data = [ ":brotli_jni", # Bazel JNI workaround @@ -51,12 +50,12 @@ java_test( "-DTEST_BUNDLE=$(location :test_bundle)", ], shard_count = 15, + test_class = "org.brotli.wrapper.enc.BrotliEncoderChannelTest", runtime_deps = [":test_lib"], ) java_test( name = "BrotliOutputStreamTest", - test_class = "org.brotli.wrapper.enc.BrotliOutputStreamTest", size = "large", data = [ ":brotli_jni", # Bazel JNI workaround @@ -67,12 +66,12 @@ java_test( "-DTEST_BUNDLE=$(location :test_bundle)", ], shard_count = 15, + test_class = "org.brotli.wrapper.enc.BrotliOutputStreamTest", runtime_deps = [":test_lib"], ) java_test( name = "EncoderTest", - test_class = "org.brotli.wrapper.enc.EncoderTest", size = "large", data = [ ":brotli_jni", # Bazel JNI workaround @@ -83,5 +82,6 @@ java_test( "-DTEST_BUNDLE=$(location :test_bundle)", ], shard_count = 15, + test_class = "org.brotli.wrapper.enc.EncoderTest", runtime_deps = [":test_lib"], ) 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); } |