From e03b1506d3644f9e4053630adc4c0620eaef71c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eirik=20Bj=C3=B8rsn=C3=B8s?= Date: Thu, 21 Nov 2024 20:04:39 +0000 Subject: [PATCH] 8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong Co-authored-by: Peter Levart Reviewed-by: jpai, rriggs --- src/java.base/share/classes/java/lang/Boolean.java | 7 +------ src/java.base/share/classes/java/lang/Integer.java | 6 +----- src/java.base/share/classes/java/lang/Long.java | 6 +----- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java index f5c643881a8..aa64d799b66 100644 --- a/src/java.base/share/classes/java/lang/Boolean.java +++ b/src/java.base/share/classes/java/lang/Boolean.java @@ -275,12 +275,7 @@ public final class Boolean implements java.io.Serializable, * @see java.lang.System#getProperty(java.lang.String, java.lang.String) */ public static boolean getBoolean(String name) { - boolean result = false; - try { - result = parseBoolean(System.getProperty(name)); - } catch (IllegalArgumentException | NullPointerException e) { - } - return result; + return name != null && !name.isEmpty() && parseBoolean(System.getProperty(name)); } /** diff --git a/src/java.base/share/classes/java/lang/Integer.java b/src/java.base/share/classes/java/lang/Integer.java index 8bf573733f2..a6bf739220f 100644 --- a/src/java.base/share/classes/java/lang/Integer.java +++ b/src/java.base/share/classes/java/lang/Integer.java @@ -1275,11 +1275,7 @@ public final class Integer extends Number * @see System#getProperty(java.lang.String, java.lang.String) */ public static Integer getInteger(String nm, Integer val) { - String v = null; - try { - v = System.getProperty(nm); - } catch (IllegalArgumentException | NullPointerException e) { - } + String v = nm != null && !nm.isEmpty() ? System.getProperty(nm) : null; if (v != null) { try { return Integer.decode(v); diff --git a/src/java.base/share/classes/java/lang/Long.java b/src/java.base/share/classes/java/lang/Long.java index e67b751470e..822199bb09b 100644 --- a/src/java.base/share/classes/java/lang/Long.java +++ b/src/java.base/share/classes/java/lang/Long.java @@ -1370,11 +1370,7 @@ public final class Long extends Number * @see System#getProperty(java.lang.String, java.lang.String) */ public static Long getLong(String nm, Long val) { - String v = null; - try { - v = System.getProperty(nm); - } catch (IllegalArgumentException | NullPointerException e) { - } + String v = nm != null && !nm.isEmpty() ? System.getProperty(nm) : null; if (v != null) { try { return Long.decode(v);