On Fri, 24 Apr 2026 21:19:05 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>)`,
>> 
>>> [], null -> NPE not thrown
>>> [en], null
>>> null, []
>>> null, [en]
>>> [null], [en]
>>> [null], [] -> NPE not thrown
>>> [], [null] -> NPE not thrown
>>> [en], [null]
>> 
>> 
>> This update fixes the empty case to correctly throw NPE. Additionally, there 
>> is a specification update to make the `null` element NPE apparent (and 
>> implementation dependent).
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Justin Lu has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Weaken spec to allow impl based decision for null elements

Changes requested by liach (Reviewer).

test/jdk/java/util/Locale/LocaleMatchingTest.java line 210:

> 208:                 Arguments.of(List.of(), null),
> 209:                 // null priority list
> 210:                 Arguments.of(null, List.of())

I think we should still reinstate some cases that has null elements, like:

Arguments.of(List.of(), Collections.singletonList(null)),
Arguments.of(Collections.singletonList(null), List.of())

-------------

PR Review: https://git.openjdk.org/jdk/pull/30632#pullrequestreview-4185179741
PR Review Comment: https://git.openjdk.org/jdk/pull/30632#discussion_r3151034519

Reply via email to