aboutsummaryrefslogtreecommitdiff
path: root/java/org/brotli/dec/BrotliInputStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/org/brotli/dec/BrotliInputStream.java')
-rw-r--r--java/org/brotli/dec/BrotliInputStream.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/java/org/brotli/dec/BrotliInputStream.java b/java/org/brotli/dec/BrotliInputStream.java
index a27e928..5cc2e28 100644
--- a/java/org/brotli/dec/BrotliInputStream.java
+++ b/java/org/brotli/dec/BrotliInputStream.java
@@ -85,7 +85,17 @@ public class BrotliInputStream extends InputStream {
}
public void setEager(boolean eager) {
- state.isEager = eager ? 1 : 0;
+ boolean isEager = (state.isEager != 0);
+ if (eager == isEager) {
+ /* Shortcut for no-op change. */
+ return;
+ }
+ if (eager) {
+ Decode.setEager(state);
+ } else {
+ /* Once decoder is "eager", there is no way back. */
+ throw new IllegalStateException("Brotli decoder has been already switched to eager mode");
+ }
}
/**