mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-30 03:21:23 +00:00
Fix NPE in o.b.c.Utils runtime and os detection
If getProperty returns null calling toLowerCase results in NPE. Instead we’ll use a default value and check for .equals(“”) in the following if.
This commit is contained in:
committed by
Andreas Schildbach
parent
5bb5de395e
commit
921a5d1aa8
@@ -561,8 +561,8 @@ public class Utils {
|
||||
private static Runtime runtime = null;
|
||||
private static OS os = null;
|
||||
static {
|
||||
String runtimeProp = System.getProperty("java.runtime.name").toLowerCase(Locale.US);
|
||||
if (runtimeProp == null)
|
||||
String runtimeProp = System.getProperty("java.runtime.name", "").toLowerCase(Locale.US);
|
||||
if (runtimeProp.equals(""))
|
||||
runtime = null;
|
||||
else if (runtimeProp.contains("android"))
|
||||
runtime = Runtime.ANDROID;
|
||||
@@ -573,8 +573,8 @@ public class Utils {
|
||||
else
|
||||
log.info("Unknown java.runtime.name '{}'", runtimeProp);
|
||||
|
||||
String osProp = System.getProperty("os.name").toLowerCase(Locale.US);
|
||||
if (osProp == null)
|
||||
String osProp = System.getProperty("os.name", "").toLowerCase(Locale.US);
|
||||
if (osProp.equals(""))
|
||||
os = null;
|
||||
else if (osProp.contains("linux"))
|
||||
os = OS.LINUX;
|
||||
|
Reference in New Issue
Block a user