8205620: Miscellaneous changes imported from jsr166 CVS 2018-07
authordl
Tue, 10 Jul 2018 10:24:08 -0700
changeset 50961 0d28f82ecac6
parent 50960 ebfb1ae41f4b
child 50962 dbe8aa90d4dd
8205620: Miscellaneous changes imported from jsr166 CVS 2018-07 Reviewed-by: martin, psandoz
src/java.base/share/classes/java/util/HashMap.java
--- 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