-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8
A DESCRIPTION OF THE PROBLEM :
The description of both ConcurrentMap.computeIfAbsent and Map.computeIfAbsent state that the return value is the current (existing or computed) value mapped for the given key.
However, the "equivalent code" snippet in the Implementation Requirements section:
if (map.get(key) == null) {
V newValue = mappingFunction.apply(key);
if (newValue != null)
return map.putIfAbsent(key, newValue);
}
Shows it returning the result of putIfAbsent(), which is defined to return the previous mapping, or null if none existed.
URL OF FAULTY DOCUMENTATION :
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentMap.html#computeIfAbsent-K-java.util.function.Function-
The description of both ConcurrentMap.computeIfAbsent and Map.computeIfAbsent state that the return value is the current (existing or computed) value mapped for the given key.
However, the "equivalent code" snippet in the Implementation Requirements section:
if (map.get(key) == null) {
V newValue = mappingFunction.apply(key);
if (newValue != null)
return map.putIfAbsent(key, newValue);
}
Shows it returning the result of putIfAbsent(), which is defined to return the previous mapping, or null if none existed.
URL OF FAULTY DOCUMENTATION :
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentMap.html#computeIfAbsent-K-java.util.function.Function-
- duplicates
-
JDK-8145164 Default implementation of ConcurrentMap::compute can throw NPE
- Closed
-
JDK-8175523 Documentation error for java.util.concurrent.ConcurrentMap#computeIfAbsent
- Closed