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

Chris Hegarty chris.hegarty at oracle.com
Thu Oct 15 11:50:56 UTC 2015


Looks good to me Sean. All other state seems to be accessed when holding zsRef.

-Chris.

On 15 Oct 2015, at 10:02, Seán Coffey <sean.coffey at oracle.com> wrote:

> 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