[concurrency-interest] 8145539: (coll) AbstractMap.keySet and .values should not be volatile

Volker.Borchert at atis-systems.com Volker.Borchert at atis-systems.com
Wed Apr 20 09:50:37 EDT 2016

> The block in navigableKeySet() is semantically the same as suggested in
> the Javadoc: it reads the non-volatile $navigableKeySet exactly once.

Sorry, I can't see the difference between

	KeySet<K> nks = navigableKeySet;
	return (nks != null) ? nks : (navigableKeySet = new KeySet<>(this));


	NavigableMap<K, V> km = descendingMap;
	return (km != null) ? km : (descendingMap = new DescendingSubMap<>(this, ...));


	EntrySet es = entrySet;
	return (es != null) ? es : (entrySet = new EntrySet());


	Collection<V> vs = values;
	return (vs != null) ? vs : (values = new Values());

but only the last one was changed. Am I just routine-blinded?

> The patch changed keySet() and values() that were doing two racy reads.

TreeMap.keySet() delegates to navigableKeySet() so the patch to AbstractMap
won't affect it.




ATIS systems GmbH 
Sitz: Bad Homburg 
Registergericht: Bad Homburg HRB 1514 
Geschaeftsfuehrer: Stefan Diepolder, Daniel Sieh

This message is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you have received this message by mistake please let us know by reply and then delete it from your system; you should not copy it or disclose its contents to anyone. All messages sent to and from ATIS systems GmbH may be monitored to ensure compliance with internal policies and to protect our business. E-Mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, lost or destroyed. Anyone who communicates with us by e-mail is taken to accept these risks.

More information about the Concurrency-interest mailing list