Inconsistent access/ synchronization on Authenticator.theAuthenticator

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Nov 17 10:28:17 UTC 2014


On 11/17/2014 12:56 PM, Dawid Weiss wrote:
> This is very minor, but java.net.Authenticator has the following
> static field for the default authenticator:
> 
>     private static Authenticator theAuthenticator;
> 
> This field is set from a synchronized method setDefault(..), but
> accessed without proper sync from all other request* methods:
> 
> Authenticator a = theAuthenticator;
> if (a == null) {
>   return null;
> }

Yes, theAuthenticator should be volatile.

Filed:
 https://bugs.openjdk.java.net/browse/JDK-8065096

-Aleksey.





More information about the core-libs-dev mailing list