-
Bug
-
Resolution: Fixed
-
P2
-
8
-
b110
-
Verified
Method
http://download.java.net/jdk8/docs/api/java/util/Map.html#computeIfPresent%28K,%20java.util.function.BiFunction%29
specifies:
Throws:
NullPointerException - if ... the remappingFunction is null
NPE is not thrown if the given key is not present, consider the following code sample:
---
new LinkedHashMap().computeIfPresent("a", (BiFunction) null);
new TreeMap().computeIfPresent("a", (BiFunction) null);
new HashMap().computeIfPresent("a", (BiFunction) null);
new HashMap(){{put("a", "a");}}.computeIfPresent("a", (BiFunction) null);
---
Only the last line will throw NPE.
The following tests will fail:
api/java_util/TreeMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/Collections/synchronizd/SynchronizedSortedMap8Tests.html#SynchronizedSortedMap8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/IdentityHashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/HashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/WeakHashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
http://download.java.net/jdk8/docs/api/java/util/Map.html#computeIfPresent%28K,%20java.util.function.BiFunction%29
specifies:
Throws:
NullPointerException - if ... the remappingFunction is null
NPE is not thrown if the given key is not present, consider the following code sample:
---
new LinkedHashMap().computeIfPresent("a", (BiFunction) null);
new TreeMap().computeIfPresent("a", (BiFunction) null);
new HashMap().computeIfPresent("a", (BiFunction) null);
new HashMap(){{put("a", "a");}}.computeIfPresent("a", (BiFunction) null);
---
Only the last line will throw NPE.
The following tests will fail:
api/java_util/TreeMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/Collections/synchronizd/SynchronizedSortedMap8Tests.html#SynchronizedSortedMap8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/IdentityHashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/HashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]
api/java_util/WeakHashMap/Map8Tests.html#Map8Tests[computeIfPresent_mappingFunctionIsNull]