RFR: 8366517: `DateFormatSymbols(Locale)` throws NPE if `Locale` argument is null [v2]

Justin Lu jlu at openjdk.org
Wed Sep 3 16:03:42 UTC 2025


On Wed, 3 Sep 2025 15:22:11 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> src/java.base/share/classes/java/text/DateFormatSymbols.java line 148:
>> 
>>> 146:      *             if the resources for the specified locale cannot be
>>> 147:      *             found or cannot be loaded.
>>> 148:      * @throws     NullPointerException if {@code locale} is null
>> 
>> Adding an explicit Objects.requireNull(locale, "locale") would clearly identify when the NPE is thrown.
>> Though it might be earlier than without the check.
>
> Right. Added the explicit null check. (and a test case)

If we are adding an explicit check to the ctor, might we also take this opportunity to add the check to the related 1-arg factory method?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27060#discussion_r2319435650


More information about the core-libs-dev mailing list