changeset 1023:2dae30c4d687

6819122: DefaultProxySelector should lazily initialize the Pattern object and the NonProxyInfo objects Summary: Move two static NonProxyInfo fields into NonProxyInfo class and instantiate Pattern object when needed Reviewed-by: jccollet
author mchung
date Wed, 25 Mar 2009 12:24:30 -0700
parents 644849201ca6
children 5303aece2068
files src/share/classes/sun/net/spi/DefaultProxySelector.java
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/spi/DefaultProxySelector.java	Tue Mar 24 19:42:23 2009 -0700
+++ b/src/share/classes/sun/net/spi/DefaultProxySelector.java	Wed Mar 25 12:24:30 2009 -0700
@@ -78,7 +78,6 @@
     };
 
     private static boolean hasSystemProxies = false;
-    private static Properties defprops = new Properties();
 
     static {
         final String key = "java.net.useSystemProxies";
@@ -107,6 +106,9 @@
         RegexpPool hostsPool;
         String property;
 
+        static NonProxyInfo ftpNonProxyInfo = new NonProxyInfo("ftp.nonProxyHosts", null, null);
+        static NonProxyInfo httpNonProxyInfo = new NonProxyInfo("http.nonProxyHosts", null, null);
+
         NonProxyInfo(String p, String s, RegexpPool pool) {
             property = p;
             hostsSource = s;
@@ -114,8 +116,6 @@
         }
     }
 
-    private static NonProxyInfo ftpNonProxyInfo = new NonProxyInfo("ftp.nonProxyHosts", null, null);
-    private static NonProxyInfo httpNonProxyInfo = new NonProxyInfo("http.nonProxyHosts", null, null);
 
     /**
      * select() method. Where all the hard work is done.
@@ -175,13 +175,13 @@
         NonProxyInfo pinfo = null;
 
         if ("http".equalsIgnoreCase(protocol)) {
-            pinfo = httpNonProxyInfo;
+            pinfo = NonProxyInfo.httpNonProxyInfo;
         } else if ("https".equalsIgnoreCase(protocol)) {
             // HTTPS uses the same property as HTTP, for backward
             // compatibility
-            pinfo = httpNonProxyInfo;
+            pinfo = NonProxyInfo.httpNonProxyInfo;
         } else if ("ftp".equalsIgnoreCase(protocol)) {
-            pinfo = ftpNonProxyInfo;
+            pinfo = NonProxyInfo.ftpNonProxyInfo;
         }
 
         /**
@@ -334,7 +334,6 @@
         }
     }
 
-    private static final Pattern p6 = Pattern.compile("::1|(0:){7}1|(0:){1,6}:1");
     private boolean isLoopback(String host) {
         if (host == null || host.length() == 0)
             return false;
@@ -364,6 +363,7 @@
         }
 
         if (host.endsWith(":1")) {
+            final Pattern p6 = Pattern.compile("::1|(0:){7}1|(0:){1,6}:1");
             return p6.matcher(host).matches();
         }
         return false;