Closed
Description
If you make a request to an IP address, the RequestHostnameResolver.resolve()
method does a reverse lookup on that IP address to try to get a hostname out of it. This occurs on line 38:
final String hostname = unresolvedAddress.getHostName();
JavaDoc for InetSocketAddress.getHostName()
says
/**
* Gets the {@code hostname}.
* Note: This method may trigger a name service reverse lookup if the
* address was created with a literal IP address.
*
* @return the hostname part of the address.
*/
I'm guessing that this behavior is unintentional. I think that we actually want getHostString()
, which says
/**
* Returns the hostname, or the String form of the address if it
* doesn't have a hostname (it was created using a literal).
* This has the benefit of <b>not</b> attempting a reverse lookup.
*
* @return the hostname, or String representation of the address.
* @since 1.7
*/
There are several calls to getHostName()
in other parts of the codebase that also look unintentional. @slandelle, any objections if I open a PR to switch this and all other occurrences to getHostString()
?