Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029055

Map.merge must refuse null values

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • Verification:
      Verified

      Backports

        Description

        Map.merge<http://download.java.net/jdk8/docs/api/java/util/Map.html#merge-K-V-java.util.function.BiFunction-&gt;states
        that its default implementation is equivalent to:

        V oldValue = map.get(key);
         V newValue = (oldValue == null) ? value :
                      remappingFunction.apply(oldValue, value);
         if (newValue == null)
             map.remove(key);
         else if (oldValue == null)
             map.remove(key);
         else
             map.put(key, newValue);

        This is not correct as for non-existing or null-value, the non-null newValuw should be added to the map.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mduigou Michael Duigou
                  Reporter:
                  henryjen Henry Jen
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  9 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: