Using URLs in Collections
java.net.URL objects used as Map keys or Set items can result in a big performance issue. Internal implementation of equals() and hashCode() methods of java.net.URL class performs domain name resolution, so the time of their execution relies on an internet connection speed. If a computer is off-line, the time is nearly equal to a connection timeout (tens of seconds).
The same problem arises every time when URLs equality checking or hash code computation is performed.
Do not use java.net.URL to keep URL values. Use java.net.URI objects or the simple Strings instead.
See also:
[...] Using URLs in Collections [...]
‘equals()’ and ‘hashCode()’ are context-sensitive « Java AntiPatterns
November 24, 2007 at 6:20 am