On 6/19/19 12:51 AM, Abraham Marín Pérez wrote:
private void decorate(Map<String, String> data) {
     //...
     data.computeIfPresent("field", (k, v) -> highlightDifferences(v, 
otherValue));
     //...
}

At one point an emptyMap() was passed to this method, causing an UOE. [...]

On the face of it, the decorate() method has the possibility to modify the map that it's passed. Thus, it shouldn't be at all surprising that passing an unmodifiable map to it results in UOE.

As a special case, it doesn't *actually* modify the map if "field" is absent, but you have to do some analysis to figure this out.

Now you want the JDK to add another special case to Collections.emptyMap(), and possibly others, in order to make this special case work. I don't think we want to do that.

s'marks

Reply via email to