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

preferIPv4Stack and preferIPv6Addresses do not affect addresses returned by HostsFileNameService

    Details

    • Subcomponent:
    • Resolved In Build:
      b26
    • Verification:
      Verified

      Description

      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]

        Attachments

          Activity

            People

            • Assignee:
              aefimov Aleksej Efimov
              Reporter:
              aefimov Aleksej Efimov
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: