changeset 55013:e2c952c7ff20

8224589: Improve startup behavior of SecurityProperties Reviewed-by: alanb
author redestad
date Wed, 22 May 2019 13:19:04 +0200
parents f982c1a6582c
children 0b56fc0448ec
files src/java.base/share/classes/sun/security/util/SecurityProperties.java
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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;
+        }
     }
 
     /**