Two hosts are considered equivalent if both host names can be resolved into the same IP addresses [...] Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP.
Two hosts are considered equivalent if both host names can be resolved into the same IP addresses [...] Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP.
Marvellous, isn't it? Just an innocent
url.equals(otherUrl)can involve a trip to the network. It may never come back. I'd like to personally "thank" the klutz who came up with that one...more...
heh. I may have had something to do with that...
back when Sun was working on RMI, I was working in Iona Technologies -- a CORBA vendor who worked with Sun on CORBA extensively -- and had written a fair bit of code and documentation on hostname-equality testing there.
In CORBA's IIOP protocol, it made sense to compare hostname equality this way -- (a) it's the only way to safely deal with multi-homed hosts; (b) of course, IIOP is an online protocol, so
DNS lookups can be used; (c) and CORBA has no HTTP-style vhosts concept so there's no danger there.
Perhaps someone in Sun heard about this, or picked up on it from the CORBA standards somewhere, and decided to codify it in java.net.URL as part of the RMI development process? (RMI was heavily CORBA-influenced.)
of course, the core "equals" method of a general HTTP-oriented class is entirely the wrong place to use this approach, as the virtual-hosting issue demonstrates. ;)