When using the JNDI-DNS provider (-Dsun.net.spi.nameservice.provider.1=dns,sun) a lookup of localhost will fail (UnknownHostException) if there is no entry for localhost.domain in the dns server. The failure could happen through InetAddress.getByName("localhost") or InetAddress.getLocalHost(). This should never happen, the dns server should not be required to have an entry for localhost.domain and we cannot count on it being there. In the case where the dns server does not have the entry we should return the loopback address.
|