RFR: 8221924: get(null) on single-entry unmodifiable Map returns null instead of throwing NPE
Lance Andersen
lance.andersen at oracle.com
Thu Apr 4 21:35:22 UTC 2019
Hi Stuart,
Minor but...
You probably want to add 8221924 to @bug in the test
Best
Lance
> On Apr 4, 2019, at 5:11 PM, Stuart Marks <stuart.marks at oracle.com> wrote:
>
> Hi all,
>
> An unmodifiable map with one entry doesn't throw NPE from get(null). Instead, it returns null. This makes it quite an outlier:
>
> Map.of().get(null) ==> NPE
> Map.of().containsKey(null) ==> NPE
> Map.of().containsValue(null) ==> NPE
>
> Map.of(1, 2).get(null) ==> returns null ***
> Map.of(1, 2).containsKey(null) ==> NPE
> Map.of(1, 2).containsValue(null) ==> NPE
>
> Map.of(1, 2, 3, 4).get(null) ==> NPE
> Map.of(1, 2, 3, 4).containsKey(null) ==> NPE
> Map.of(1, 2, 3, 4).containsValue(null) ==> NPE
>
> It should be fixed to throw NPE like all the other cases.
>
> This is a tiny incompatible change, so I intend to file a CSR. Tier1, 2, and 3 tests all pass though.
>
> I think this change should also be backported to 11. We're fairly early in the 11 LTS lifetime, so it'd be good to fix this now.
>
> Bug:
>
> https://bugs.openjdk.java.net/browse/JDK-8221924
>
> Webrev:
>
> http://cr.openjdk.java.net/~smarks/reviews/8221924/webrev.0/
>
> Thanks,
>
> s'marks
<http://oracle.com/us/design/oracle-email-sig-198324.gif>
<http://oracle.com/us/design/oracle-email-sig-198324.gif> <http://oracle.com/us/design/oracle-email-sig-198324.gif>
<http://oracle.com/us/design/oracle-email-sig-198324.gif>Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
Lance.Andersen at oracle.com <mailto:Lance.Andersen at oracle.com>
More information about the core-libs-dev
mailing list