JDK-2175190 : DefaultProxySelector should lazily initialize the Pattern object and the NonProxyInfo objects
  • Type: Backport
  • Backport of: JDK-6819122
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2009-04-01
  • Updated: 2014-04-16
  • Resolved: 2009-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u14 b05Fixed 7Fixed
Comments
SUGGESTED FIX @@ -91,19 +91,20 @@ static class NonProxyInfo { String hostsSource; 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; hostsPool = pool; } } - 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. * Build a list of proxies depending on URI. * Since we're only providing compatibility with the system properties @@ -152,17 +153,17 @@ List<Proxy> proxyl = new ArrayList<Proxy>(1); 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; } /** * Let's check the System properties for that protocol */ @@ -332,11 +333,10 @@ } else { return -1; } } - 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; if (host.equalsIgnoreCase("localhost")) @@ -362,10 +362,11 @@ if ((q = scanByte(host, p, n)) <= p) return false; return q == n && number > 0; } if (host.endsWith(":1")) { + final Pattern p6 = Pattern.compile("::1|(0:){7}1|(0:){1,6}:1"); return p6.matcher(host).matches(); } return false; }
09-04-2009

EVALUATION Reduce the number of classes loaded. Backport to 6u14.
01-04-2009