8224589: Improve startup behavior of SecurityProperties
authorredestad
Wed, 22 May 2019 13:19:04 +0200
changeset 54980 e2c952c7ff20
parent 54979 f982c1a6582c
child 54981 0b56fc0448ec
8224589: Improve startup behavior of SecurityProperties Reviewed-by: alanb
src/java.base/share/classes/sun/security/util/SecurityProperties.java
--- a/src/java.base/share/classes/sun/security/util/SecurityProperties.java	Wed May 22 06:29:08 2019 -0400
+++ b/src/java.base/share/classes/sun/security/util/SecurityProperties.java	Wed May 22 13:19:04 2019 +0200
@@ -43,15 +43,20 @@
      * @return the value of the system or security property
      */
     public static String privilegedGetOverridable(String propName) {
-        return AccessController.doPrivileged((PrivilegedAction<String>)
-            () -> {
-                String val = System.getProperty(propName);
-                if (val == null) {
-                    return Security.getProperty(propName);
-                } else {
-                    return val;
-                }
-            });
+        if (System.getSecurityManager() == null) {
+            return getOverridableProperty(propName);
+        } else {
+            return AccessController.doPrivileged((PrivilegedAction<String>) () -> getOverridableProperty(propName));
+        }
+    }
+
+    private static String getOverridableProperty(String propName) {
+        String val = System.getProperty(propName);
+        if (val == null) {
+            return Security.getProperty(propName);
+        } else {
+            return val;
+        }
     }
 
     /**