RFR (xs) : 8038502: Deflater.needsInput() should use synchronization

Seán Coffey sean.coffey at oracle.com
Thu Oct 15 09:02:40 UTC 2015


bug report : https://bugs.openjdk.java.net/browse/JDK-8038502

The len instance variable should be read/written while holding the zsRef 
lock.

needsInput() seems to be missing that. Simple change :

diff --git a/src/java.base/share/classes/java/util/zip/Deflater.java 
b/src/java.base/share/classes/java/util/zip/Deflater.java
--- a/src/java.base/share/classes/java/util/zip/Deflater.java
+++ b/src/java.base/share/classes/java/util/zip/Deflater.java
@@ -318,8 +318,10 @@
       * should be called in order to provide more input
       */
      public boolean needsInput() {
+        synchronized (zsRef) {
          return len <= 0;
      }
+    }

      /**
       * When called, indicates that compression should end with the current

-- 
Regards,
Sean.




More information about the core-libs-dev mailing list