RFR: 8375016: Several catch blocks for NullPointerExceptions exist in the codebase
Christopher Schnick
duke at openjdk.org
Mon Jan 12 17:23:49 UTC 2026
On Mon, 12 Jan 2026 16:41:41 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
>> This PR replaces various catch blocks for NPEs by proper null checks. It looks like a lot but most of the binding changes are just variants of the same approach. The test cases have been adapted to not check for NPEs anymore.
>>
>> The PrismFontFactory change to a RuntimeException was made because I don't see how the try block can throw an NPE.
>
> modules/javafx.base/src/main/java/javafx/beans/binding/Bindings.java line 7478:
>
>> 7476: return val;
>> 7477: } else {
>> 7478: Logging.getLogger().fine("Element not found in map, returning default value instead.");
>
> Why did you add this check? The old implementation doesn't check whether the mapping exists, it simply returns the result of `Map.get()`.
>
> On the other hand, `NullPointerException` is thrown by `Map.get()` if the key is null, and the map doesn't permit null keys. The old implementation would return null here end emit a warning, this implementation returns by throwing the exception.
Ok that is true, let me rework this PR
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2032#discussion_r2683195003
More information about the openjfx-dev
mailing list