JDK-8244958 : preferIPv4Stack and preferIPv6Addresses do not affect addresses returned by HostsFileNameService
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2020-05-13
  • Updated: 2020-06-06
  • Resolved: 2020-05-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b26Fixed
Sub Tasks
JDK-8248328 :  
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]

Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/811be96aa6d4 User: aefimov Date: 2020-05-29 12:41:19 +0000
29-05-2020