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

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 7
    • Component/s: 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.

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

              Created:
              Updated:
              Imported:
              Indexed: