8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong
Co-authored-by: Peter Levart <plevart@openjdk.org> Reviewed-by: jpai, rriggs
This commit is contained in:
parent
d6b40d3033
commit
e03b1506d3
@ -275,12 +275,7 @@ public final class Boolean implements java.io.Serializable,
|
|||||||
* @see java.lang.System#getProperty(java.lang.String, java.lang.String)
|
* @see java.lang.System#getProperty(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public static boolean getBoolean(String name) {
|
public static boolean getBoolean(String name) {
|
||||||
boolean result = false;
|
return name != null && !name.isEmpty() && parseBoolean(System.getProperty(name));
|
||||||
try {
|
|
||||||
result = parseBoolean(System.getProperty(name));
|
|
||||||
} catch (IllegalArgumentException | NullPointerException e) {
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1275,11 +1275,7 @@ public final class Integer extends Number
|
|||||||
* @see System#getProperty(java.lang.String, java.lang.String)
|
* @see System#getProperty(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public static Integer getInteger(String nm, Integer val) {
|
public static Integer getInteger(String nm, Integer val) {
|
||||||
String v = null;
|
String v = nm != null && !nm.isEmpty() ? System.getProperty(nm) : null;
|
||||||
try {
|
|
||||||
v = System.getProperty(nm);
|
|
||||||
} catch (IllegalArgumentException | NullPointerException e) {
|
|
||||||
}
|
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
try {
|
try {
|
||||||
return Integer.decode(v);
|
return Integer.decode(v);
|
||||||
|
@ -1370,11 +1370,7 @@ public final class Long extends Number
|
|||||||
* @see System#getProperty(java.lang.String, java.lang.String)
|
* @see System#getProperty(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public static Long getLong(String nm, Long val) {
|
public static Long getLong(String nm, Long val) {
|
||||||
String v = null;
|
String v = nm != null && !nm.isEmpty() ? System.getProperty(nm) : null;
|
||||||
try {
|
|
||||||
v = System.getProperty(nm);
|
|
||||||
} catch (IllegalArgumentException | NullPointerException e) {
|
|
||||||
}
|
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
try {
|
try {
|
||||||
return Long.decode(v);
|
return Long.decode(v);
|
||||||
|
Loading…
Reference in New Issue
Block a user