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.

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

Commit messages:
 - init

Changes: https://git.openjdk.org/jdk/pull/30632/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30632&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8381644
  Stats: 129 lines in 3 files changed: 89 ins; 10 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/30632.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30632/head:pull/30632

PR: https://git.openjdk.org/jdk/pull/30632

Reply via email to