JDK-6346071 : Problem with lookups of localhost with JNDI-DNS provider
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-11-04
  • Updated: 2010-04-02
  • Resolved: 2005-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
6 b63Fixed
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.

EVALUATION in the case where the lookup fails and the hostname being looked up is localhost return the loopback address.