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

InetAddress.getLocalHost() may return different results with java.net.preferIPv4Stack=true and false

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • generic
    • generic

      I've discovered that InetAddress.getLocalHost() returns different IP addresses on one of our machines with default options and -Djava.net.preferIPv4Stack=true. After some insvestigation, it occured that machine was reconfigured and had IP address changed in Network Settings. At the same time, it still had old IP address in C:\Windows\system32\drivers\etc\hosts.

      To summarize:
      With -Djava.net.preferIPv4Stack=true, it returns correct IP address (from network settings).
      With -Djava.net.preferIPv4Stack=false, it returns IP address from hosts file (from hosts file).

      It appears that new code uses name resolver to obtain local host address while old one doesn't.

            aefimov Aleksej Efimov
            nhaustov Nicolay Haustov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: