changeset 50961:0d28f82ecac6

8205620: Miscellaneous changes imported from jsr166 CVS 2018-07 Reviewed-by: martin, psandoz
author dl
date Tue, 10 Jul 2018 10:24:08 -0700
parents ebfb1ae41f4b
children dbe8aa90d4dd
files src/java.base/share/classes/java/util/HashMap.java
diffstat 1 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/HashMap.java	Tue Jul 10 10:24:08 2018 -0700
+++ b/src/java.base/share/classes/java/util/HashMap.java	Tue Jul 10 10:24:08 2018 -0700
@@ -1263,9 +1263,7 @@
     @Override
     public V merge(K key, V value,
                    BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
-        if (value == null)
-            throw new NullPointerException();
-        if (remappingFunction == null)
+        if (value == null || remappingFunction == null)
             throw new NullPointerException();
         int hash = hash(key);
         Node<K,V>[] tab; Node<K,V> first; int n, i;
@@ -1308,8 +1306,7 @@
             else
                 removeNode(hash, key, null, false, true);
             return v;
-        }
-        if (value != null) {
+        } else {
             if (t != null)
                 t.putTreeVal(this, tab, hash, key, value);
             else {
@@ -1320,8 +1317,8 @@
             ++modCount;
             ++size;
             afterNodeInsertion(true);
+            return value;
         }
-        return value;
     }
 
     @Override