3 ms·
You'd think that is so completely wrong that no competent programmer would ever do it... Except the java.net.URL.equals and java.net.URL.hashcode methods do al
by nl 5y ago
You'd think that is so completely wrong that no competent programmer would ever do it...
Except the java.net.URL.equals and java.net.URL.hashcode methods do almost the same thing: they issue DNS requests (!)
"Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null."
See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/URL.html#equals(java.lang.Object) https://docs.oracle.com/en/java/javase/11/docs/api/java.base...
There is a bug raised[1], but it can't be fixed for backwards compatibility reasons.
I'll never forget this now, after debugging a very horrible and severe and very intermittent performance issue in some code over 20 years ago. A (slow) DNS resolver occasionally caused 1000x performance degradation on remote sites. That was horrible to work out.
[1] https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4434494 https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4434494