Integrated: 8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong

Eirik Bjørsnøs eirbjo at openjdk.org
Thu Nov 21 20:07:23 UTC 2024


On Sun, 17 Nov 2024 14:52:06 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> Please review this PR which removes exceptional control flow in `Boolean::getBoolean`, `Integer::getInteger` and `Long::getLong`.
> 
> These methods are catching `IllegalArgumentException` and `NullPointerException`, thrown by `System::getProperty` via `System::checkKey`. This PR replaces the exceptional control flow with explicit checks that the system property name is non-null and non-empty before calling into `System::getProperty`.
> 
> As JDK-8178966 points out, there is a possibility that System.getProperty could throw one of NPE and IAE for other reasons than the name being null or empty. This risk is reduced now that custom security managers cannot interfere. Adding to that, if such exceptions are thrown today, they are masked by these methods catching and swallowing them by returning false or default values. It's better to expose such  bugs if they exist.
> 
> GHA results pending. Local tier2 ran successfully.

This pull request has now been integrated.

Changeset: e03b1506
Author:    Eirik Bjørsnøs <eirbjo at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e03b1506d3644f9e4053630adc4c0620eaef71c0
Stats:     16 lines in 3 files changed: 0 ins; 13 del; 3 mod

8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong

Co-authored-by: Peter Levart <plevart at openjdk.org>
Reviewed-by: jpai, rriggs

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

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


More information about the core-libs-dev mailing list