Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4163652

InetAddress.getLocalHost returns first line in /etc/hosts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • sparc
    • solaris_2.6



      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)
      ======================================================================

            shihliu Sharon Liu (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: