hashCode()
and equals()
being called on java.net.URL
objects.
The java.net.URL
class internally uses an instance of java.net.URLStreamHandler
to execute hashCode()
and equals()
.
This can cause performance problems because java.net.URLStreamHandler
performs DNS lookups.
Depending on the availability of the network and the speed of a DNS server this can cause significant delays.
The problem can most likely be solved by using java.net.URI
instead.
Example:
int f(URL url1, URL url2) {
if (url1.equals(url2)) return url1.hashCode();
else return url2.hashCode();
}