JDK-4163652 : InetAddress.getLocalHost returns first line in /etc/hosts
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1998-08-05
  • Updated: 1998-10-29
  • Resolved: 1998-10-29
Related Reports
Duplicate :  
Description

Name: diC59631			Date: 08/05/98


1. The error occurrs under the following circumstances:
   -nscd is not running
   -"files" is the first entry in hosts of /etc/nsswitch.conf

2. program:
import java.net.*;
 
public class LocalName
{
    public static void main(String args[]) throws Exception
    {
        System.out.println("InetAddress.getLocalHost(): "
            + InetAddress.getLocalHost());
    }
}

3. The output is the first host in /etc/hosts (which
   may be any host).

The problem seems to appear in any Java Version
including 1.1.5, 1.2Beta4 under Solaris2.5 and
Solaris2.6.

4. Seems to be a simular problem like bug id
   4073539, which is marked to be fixed, but 
   I can reproduce the error on JDK1.2Beta4 (local
   host is wspain, first entry in /etc/hosts is
   svstch):

(wspain:~/java/gethost) java -version
java version "1.2beta4"
Classic VM (build JDK-1.2beta4-K, green threads, sunwjit)
(wspain:~/java/gethost) java LocalName
InetAddress.getLocalHost(): svstch/137.156.206.3
(Review ID: 36370)
======================================================================

Comments
WORK AROUND Name: diC59631 Date: 08/05/98 - run nscd (may cause other problems) - put local host as first entry to /etc/hosts - use name service (dns/nisplus) before "files" int /etc/nsswitch.conf ======================================================================
11-06-2004

EVALUATION sharon.liu@eng 1998-10-29 This is a duplicate of bug 4073539.
29-10-1998