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

Peter Levart peter.levart at gmail.com
Tue Jun 19 11:17:09 UTC 2018



On 06/18/2018 06:53 PM, Claes Redestad wrote:
>> Plain write that follows in program a volatile write, can in theory 
>> float before the volatile write. So if you publish a Properties 
>> instance via data race (via plain write), the observer may still see 
>> uninitialized 'map' and 'defaults' fields.
>>
>
> Right
>
> http://cr.openjdk.java.net/~redestad/8199435.01/
>
> (Yes, using VarHandle.storeStoreFence would do the exact same thing, 
> but is not usable from Properties as the VarHandle impl needs to read 
> some system properties...)
>
> /Claes 

This looks good to me. One might think that the same fence is needed in 
deserialization too (readHashtable), but ObjectInputStream already makes 
care of that (see ObjectInputStream.freeze() and the two calls in 
readObject() and readUnshared()), so this is fine now.

Regards, Peter



More information about the core-libs-dev mailing list