-
Bug
-
Resolution: Fixed
-
P3
-
None
-
None
ConcurrentHashMap (unlike ConcurrentSkipListMap) was architected to run a mapping function at most once in methods compute, computeIfAbsent, computeIfPresent (essentially by locking the key's bin).
But this should be better documented and tested.
There was wording added to the computeIfAbsent spec, but unfortunately not to compute and computeIfPresent, suggesting that computeIfAbsent's behavior is somehow distinct when it is not. Also, computeIfAbsent's spec should be clarified. I had trouble with """The entire method invocation is performed atomically, so the function is applied at most once per key. """
All ConcurrentMap implementations update atomically, so perhaps simply say """the function is applied at most once per key"""
Discussion at
https://concurrency.markmail.org/thread/vlm4a4ouho7snqfb
But this should be better documented and tested.
There was wording added to the computeIfAbsent spec, but unfortunately not to compute and computeIfPresent, suggesting that computeIfAbsent's behavior is somehow distinct when it is not. Also, computeIfAbsent's spec should be clarified. I had trouble with """The entire method invocation is performed atomically, so the function is applied at most once per key. """
All ConcurrentMap implementations update atomically, so perhaps simply say """the function is applied at most once per key"""
Discussion at
https://concurrency.markmail.org/thread/vlm4a4ouho7snqfb
- csr for
-
JDK-8232652 Clarify that ConcurrentHashMap compute methods mapping functions execute at most once
-
- Closed
-