RFR 8199435 : Unsafe publication of java.util.Properties.map
Brent Christian
brent.christian at oracle.com
Fri Jun 15 18:01:51 UTC 2018
On 6/15/18 10:35 AM, Paul Sandoz wrote:
>
> I would also publish the map in readHashtable after you have placed in the keys/values.
>
Like this?
// create CHM of appropriate capacity
- map = new ConcurrentHashMap<>(elements);
+ ConcurrentHashMap<Object,Object> tmpMap = new
ConcurrentHashMap<>(elements);
// Read all the key/value objects
for (; elements > 0; elements--) {
Object key = s.readObject();
Object value = s.readObject();
- map.put(key, value);
+ tmpMap.put(key, value);
}
+
+ UNSAFE.putObjectVolatile(this, MAP_OFFSET, tmpMap);
}
-B
More information about the core-libs-dev
mailing list