< prev index next >

src/java.base/share/classes/sun/nio/ch/Net.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs

@@ -31,10 +31,11 @@
 import java.nio.channels.*;
 import java.util.*;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import sun.net.ExtendedOptionsImpl;
+import sun.security.action.GetPropertyAction;
 
 
 public class Net {
 
     private Net() { }

@@ -380,17 +381,12 @@
             return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
         }
     }
 
     public static boolean isFastTcpLoopbackRequested() {
-        String loopbackProp = java.security.AccessController.doPrivileged(
-            new PrivilegedAction<String>() {
-                @Override
-                public String run() {
-                    return System.getProperty("jdk.net.useFastTcpLoopback");
-                }
-            });
+        String loopbackProp =
+                GetPropertyAction.getProperty("jdk.net.useFastTcpLoopback");
         boolean enable;
         if ("".equals(loopbackProp)) {
             enable = true;
         } else {
             enable = Boolean.parseBoolean(loopbackProp);

@@ -645,20 +641,13 @@
 
     static {
         int availLevel = isExclusiveBindAvailable();
         if (availLevel >= 0) {
             String exclBindProp =
-                java.security.AccessController.doPrivileged(
-                    new PrivilegedAction<String>() {
-                        @Override
-                        public String run() {
-                            return System.getProperty(
-                                    "sun.net.useExclusiveBind");
-                        }
-                    });
+                    GetPropertyAction.getProperty("sun.net.useExclusiveBind");
             if (exclBindProp != null) {
-                exclusiveBind = exclBindProp.length() == 0 ?
+                exclusiveBind = exclBindProp.isEmpty() ?
                         true : Boolean.parseBoolean(exclBindProp);
             } else if (availLevel == 1) {
                 exclusiveBind = true;
             } else {
                 exclusiveBind = false;
< prev index next >