On Wed, 8 Apr 2026 17:21:43 GMT, Justin Lu <[email protected]> wrote: > This PR standardizes the null related behavior for the `Locale` filtering and > lookup APIs. > > There are two issues. First, null elements within either `Collection` which > are passed to these APIs may cause NPE, but this is not specified. Second, if > the `tags` or `locales` list is null and `priorityList` empty, NPE is not > thrown (even though it is specified to). > > For example, this is the current null related behavior for > `Locale:lookup(List<LanguageRange>, Collection<Locale>)` (where all cases > should throw NPE), > >> [], null -> NPE not thrown >> [en], null >> null, [] >> null, [en] >> [null], [en] >> [null], [] -> NPE not thrown >> [], [null] -> NPE not thrown >> [en], [null] > > > This update ensures that when either `Collection` is null, or any elements > within are null, NPE is always thrown. That is, the empty edge case does not > mask the NPE. The fix for null elements is done in the empty case conditional > within `LocaleMatcher`, since the standard cases naturally encounter NPE. The > specification is updated to fill in the missing behavior. As this also > creates a behavioral change (to match the expected API contract), a CSR is > filed.
Or what if we "accept" null elements, which would be simply ignored? That would avoid NPE crash. ------------- PR Comment: https://git.openjdk.org/jdk/pull/30632#issuecomment-4210687793
