6819122: DefaultProxySelector should lazily initialize the Pattern object and the NonProxyInfo objects
Move two static NonProxyInfo fields into NonProxyInfo class and instantiate Pattern object when needed Reviewed-by: jccollet
This commit is contained in:
parent
01a36018d3
commit
5d6fffa036
@ -78,7 +78,6 @@ public class DefaultProxySelector extends ProxySelector {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static boolean hasSystemProxies = false;
|
private static boolean hasSystemProxies = false;
|
||||||
private static Properties defprops = new Properties();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final String key = "java.net.useSystemProxies";
|
final String key = "java.net.useSystemProxies";
|
||||||
@ -107,6 +106,9 @@ public class DefaultProxySelector extends ProxySelector {
|
|||||||
RegexpPool hostsPool;
|
RegexpPool hostsPool;
|
||||||
String property;
|
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) {
|
NonProxyInfo(String p, String s, RegexpPool pool) {
|
||||||
property = p;
|
property = p;
|
||||||
hostsSource = s;
|
hostsSource = s;
|
||||||
@ -114,8 +116,6 @@ public class DefaultProxySelector extends ProxySelector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
* select() method. Where all the hard work is done.
|
||||||
@ -175,13 +175,13 @@ public class DefaultProxySelector extends ProxySelector {
|
|||||||
NonProxyInfo pinfo = null;
|
NonProxyInfo pinfo = null;
|
||||||
|
|
||||||
if ("http".equalsIgnoreCase(protocol)) {
|
if ("http".equalsIgnoreCase(protocol)) {
|
||||||
pinfo = httpNonProxyInfo;
|
pinfo = NonProxyInfo.httpNonProxyInfo;
|
||||||
} else if ("https".equalsIgnoreCase(protocol)) {
|
} else if ("https".equalsIgnoreCase(protocol)) {
|
||||||
// HTTPS uses the same property as HTTP, for backward
|
// HTTPS uses the same property as HTTP, for backward
|
||||||
// compatibility
|
// compatibility
|
||||||
pinfo = httpNonProxyInfo;
|
pinfo = NonProxyInfo.httpNonProxyInfo;
|
||||||
} else if ("ftp".equalsIgnoreCase(protocol)) {
|
} else if ("ftp".equalsIgnoreCase(protocol)) {
|
||||||
pinfo = ftpNonProxyInfo;
|
pinfo = NonProxyInfo.ftpNonProxyInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -334,7 +334,6 @@ public class DefaultProxySelector extends ProxySelector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern p6 = Pattern.compile("::1|(0:){7}1|(0:){1,6}:1");
|
|
||||||
private boolean isLoopback(String host) {
|
private boolean isLoopback(String host) {
|
||||||
if (host == null || host.length() == 0)
|
if (host == null || host.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -364,6 +363,7 @@ public class DefaultProxySelector extends ProxySelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (host.endsWith(":1")) {
|
if (host.endsWith(":1")) {
|
||||||
|
final Pattern p6 = Pattern.compile("::1|(0:){7}1|(0:){1,6}:1");
|
||||||
return p6.matcher(host).matches();
|
return p6.matcher(host).matches();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user