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

InetAddress get local host fails on Solaris in some cases

XMLWordPrintable

    • 1.2.2
    • unknown, sparc
    • solaris_2.5.1, solaris_2.6

      If the first entry of /etc/hosts is localhost on Solaris, the getLocalHost call will return "localhost".


      dale.mcduffie@Eng 1998-09-30
      ----------------------------
      A customer reports that this bug is in fact not fixed in 1.2beta4: they are not
      using NIS. I am unable to find a non-NIS machine, but believe that the customer
      is correct. Here is the call with the test case:

      Bug #4073539 describes how java.net.InetAddress.getLocalHost()
      returns the first entry in /etc/hosts instead of the correct
      address. That bug page is labeled "closed, fixed in 1.2beta4,
      1998-04-13". However, the bug is still present in 1.2beta4
      on my Solaris 2.6 system, as seen below.


      [baskerville] uname -a
      SunOS baskerville.CS.Arizona.EDU 5.6 Generic_105181-06 sun4u sparc SUNW,Ultra-1
      [baskerville] java -version
      java version "1.2beta4"
      Classic VM (build JDK-1.2beta4-K, green threads, sunwjit)
      [baskerville] java -fullversion
      java full version "JDK-1.2beta4-K"
      [baskerville]
      [baskerville] cat t.java

      import java.net.*;

      class t {
          public static void main (String args[]) {
              try {
                  System.out.println(InetAddress.getLocalHost().getHostName());
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

      [baskerville]
      [baskerville] javac t.java
      [baskerville] java t
      localhost
      [baskerville]

            shihliu Sharon Liu (Inactive)
            brenaudsunw Benjamin Renaud (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: