URLStreamHandler.getHostAddress() performance
Wang Weijun
weijun.wang at oracle.com
Tue Nov 25 12:02:45 UTC 2014
I am benchmarking security manager and notice this
protected synchronized InetAddress getHostAddress(URL u) {
if (u.hostAddress != null)
return u.hostAddress;
String host = u.getHost();
if (host == null || host.equals("")) {
return null;
} else {
try {
u.hostAddress = InetAddress.getByName(host);
} catch (UnknownHostException ex) {
return null;
} catch (SecurityException se) {
return null;
}
}
return u.hostAddress;
}
Is there any reason why the method is synchronized? Why not simply "synchronized (u)"?
Thanks
Max
More information about the security-dev
mailing list