RFC: Adding ConcurrentModificationException for HashMap.computeIfAbsent(), and JDK-8071667

Ben Manes ben_manes at yahoo.com
Fri Mar 6 23:57:08 UTC 2015


I'd recommend that the exception thrown should be an IllegalStateException. This is documented in ConcurrentHashMap's computeIfAbsent as,

* @throws IllegalStateException if the computation detectably
*         attempts a recursive update to this map that would

*         otherwise never complete

The detection logic is in Doug's repository to be merged in for JDK-8062841.

It is also unexpected to have a concurrent data structure throw a ConcurrentModificationException, which is why I believe that IllegalStateException was chosen for ConcurrentHashMap.



More information about the core-libs-dev mailing list