RFR 8199435 : Unsafe publication of java.util.Properties.map

Paul Sandoz paul.sandoz at oracle.com
Fri Jun 15 17:35:20 UTC 2018



> On Jun 15, 2018, at 8:44 AM, Brent Christian <brent.christian at oracle.com> wrote:
> 
> Hi,
> 
> In JDK 9, 8029891[1] refactored java.util.Properties to store its values in an internal ConcurrentHashMap, and removed synchronization from "reader" methods in order to avoid potential hangs/deadlocks during classloading.
> 
> Claes has noticed that there is the possibility of the new 'map' field being observed with its default value (null), before being set.
> 

Yes.

I would also publish the map in readHashtable after you have placed in the keys/values.

Pail.

> After looking at the JSR 133 FAQ[2], I agree with Claes that we should make 'map' a field final.
> 
> Please review my change to do this:
> 
> Webrev:
> http://cr.openjdk.java.net/~bchristi/8199435/webrev/
> Issue:
> https://bugs.openjdk.java.net/browse/JDK-8199435
> 
> Thanks,
> -Brent
> 
> 1. https://bugs.openjdk.java.net/browse/JDK-8029891
> 2. https://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#finalRight



More information about the core-libs-dev mailing list