I just found the post Mr. Gosling - why did you make URL equals suck?!? on programming.reddit.com and just had to share
Okay, I’m totally hacked! java.net.URL class officially sucks! The
equals method on this shining example of the JDK API mess actually does
a blocking DNS lookup on the host string to resolve to an IP address
and then compares the IP addresses rather than the host string. What
freakin’ sense does that make?
URL url1 = new URL("http://foo.example.com");
URL url2 = new URL("http://example.com");
Let’s say these map to these IP addresses:
http://foo.example.com => 245.10.10.1
http://example.com => 245.10.10.1
Here’s the scary part:
url1.equals(url2) => true!
That's definitely the best example of code that deserves to be on The Daily WTF I've seen from a standard library. Just thinking about all the code I have in RSS Bandit that tests URLs for equality, it boggles my mind to think a standard library could have such a craptacular implementation of the
Anyone have similar examples from other standard libraries (C++, .NET, JDK, Ruby, etc)? I need some bad code to cheer me up after a day that's already had too many meetings. :)