-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b16
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8228925 | 12u-cpu | Stuart Marks | P3 | Resolved | Fixed | master |
JDK-8222932 | 12.0.2 | Stuart Marks | P3 | Resolved | Fixed | b03 |
JDK-8223095 | 11.0.5-oracle | Robert Mckenna | P3 | Resolved | Fixed | b01 |
JDK-8222954 | 11.0.4 | Stuart Marks | P3 | Resolved | Fixed | b01 |
The unmodifiable maps are supposed to be null-hostile. However, a one-entry unmodifiable map will simply return null when get(null) is called. This is inconsistent with the behavior of other unmodifiable maps that have different numbers of elements.
Map.of().get(null) ==> throws NPE
Map.of(1, 2).get(null) ==> returns null
Map.of(1, 2, 3, 4).get(null) ==> throws NPE
Moreover, containsKey(null) and containsValue(null) on all unmodifiable maps throw NPE, and contains(null) on unmodifiable lists and sets all throw NPE. Thus, the get(null) behavior should be modified also to throw NPE.
Thanks to Claes Redestad for spotting this.
This fix should be backported to 12 and 11 as well.
Map.of().get(null) ==> throws NPE
Map.of(1, 2).get(null) ==> returns null
Map.of(1, 2, 3, 4).get(null) ==> throws NPE
Moreover, containsKey(null) and containsValue(null) on all unmodifiable maps throw NPE, and contains(null) on unmodifiable lists and sets all throw NPE. Thus, the get(null) behavior should be modified also to throw NPE.
Thanks to Claes Redestad for spotting this.
This fix should be backported to 12 and 11 as well.
- backported by
-
JDK-8222932 get(null) on single-entry unmodifiable Map returns null instead of throwing NPE
- Resolved
-
JDK-8222954 get(null) on single-entry unmodifiable Map returns null instead of throwing NPE
- Resolved
-
JDK-8223095 get(null) on single-entry unmodifiable Map returns null instead of throwing NPE
- Resolved
-
JDK-8228925 get(null) on single-entry unmodifiable Map returns null instead of throwing NPE
- Resolved
- csr for
-
JDK-8222002 get(null) on single-entry unmodifiable Map returns null instead of throwing NPE
- Closed