8221924: get(null) on single-entry unmodifiable Map returns null instead of throwing NPE

Reviewed-by: redestad, lancea
This commit is contained in:
Stuart Marks 2019-04-09 09:49:36 -07:00
parent b0c2b42e40
commit 1aa784cdac
2 changed files with 12 additions and 2 deletions

View file

@ -881,6 +881,11 @@ class ImmutableCollections {
return Set.of(new KeyValueHolder<>(k0, v0));
}
@Override
public V get(Object o) {
return o.equals(k0) ? v0 : null; // implicit nullcheck of o
}
@Override
public boolean containsKey(Object o) {
return o.equals(k0); // implicit nullcheck of o