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

preferIPv4Stack and preferIPv6Addresses do not affect addresses returned by HostsFileNameService

XMLWordPrintable

    • b26
    • Verified

      The "java.net.preferIPv4Stack" and "java.net.preferIPv6Addresses" system properties are specified to affect the ordering and filtering of addresses returned by InetAddress::getAllByName. However they seem to have no effect when the HostsFileNameService provider is selected by specifying the "jdk.net.hosts.file" system property.

      It is better to make the platform name service and the hosts file name service to behave similarly with respect to the mentioned system properties.

      The following test file that is set as hosts file name service (-Djdk.net.hosts.file=testHostsFile.txt):
      127.0.0.1 localhost
      ::1 ip6-localhost ip6-loopback

      3.216.223.146 testHost.com
      3.213.162.208 testHost.com
      2406:da00:ff10:0:0:0:3447:4a6b testHost.com
      2406:da00:ff10:0:0:0:3448:ad37 testHost.com


      InetAddress.getAllByName("testHost.com") with no system properties set:
      [testHost.com/3.216.223.146, testHost.com/3.213.162.208, testHost.com/2406:da00:ff10:0:0:0:3447:4a6b, testHost.com/2406:da00:ff10:0:0:0:3448:ad37]

      InetAddress.getAllByName("testHost.com") results with -Djava.net.preferIPv4Stack=true:
      [testHost.com/3.216.223.146, testHost.com/3.213.162.208, testHost.com/2406:da00:ff10:0:0:0:3447:4a6b, testHost.com/2406:da00:ff10:0:0:0:3448:ad37]

      InetAddress.getAllByName("testHost.com") results with -Djava.net.preferIPv6Addresses=true:
      [testHost.com/3.216.223.146, testHost.com/3.213.162.208, testHost.com/2406:da00:ff10:0:0:0:3447:4a6b, testHost.com/2406:da00:ff10:0:0:0:3448:ad37]

        There are no Sub-Tasks for this issue.

            aefimov Aleksej Efimov
            aefimov Aleksej Efimov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: