JDK-8220083 : Remove hard-coded 127.0.0.1 loopback address in JDK networking tests
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-03-04
  • Updated: 2024-05-24
  • Resolved: 2019-03-12
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 11 JDK 13
11.0.22Fixed 13 b12Fixed
Description
Some of the JDK networking tests use hard-coded 127.0.0.1, loopback address. This works on IPv4 or IPv6&IPv4 network. However, with IPv6-only network, those tests with hard-coded address fail. The following fix would work for IPv4, IPv6&IPv4, and IPv6-only environment:

-            so = new Socket("127.0.0.1", port);
+            so = new Socket(InetAddress.getLoopbackAddress(), port);
Comments
Should we adjust a few more locations like those : https://github.com/openjdk/jdk/blob/c4c66aba93cf061d487eddbd18e9e7e3e9c9f3a8/test/jdk/sun/security/ssl/SSLSocketImpl/ReverseNameLookup.java#L134 https://github.com/openjdk/jdk/blob/c4c66aba93cf061d487eddbd18e9e7e3e9c9f3a8/test/jdk/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java#L145 https://github.com/openjdk/jdk/blob/c4c66aba93cf061d487eddbd18e9e7e3e9c9f3a8/test/jdk/java/net/SocketImpl/SocketImplCombinations.java#L97
30-10-2023

Fix request [11u] I backport this test improvement as prereq of JDK-8223145. Should be useful anyways. No risk, only a test change. Needed some trivial resolves and adaptions. Tests pass. SAP nightly testing passed.
27-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/2222 Date: 2023-10-26 14:08:19 +0000
26-10-2023

The pushes of this change use a different heading: "8220083: Use InetAddress.getLoopbackAddress() in place of 127.0.0.1 for some test"
18-03-2022

Git URL: https://github.com/openjdk/jdk/commit/ef9ce3be1e33f1a45a6d8fbcbe3d4ceffcf7c4ce
16-03-2022

URL: http://hg.openjdk.java.net/jdk/jdk/rev/ccb4a50bee06 User: jiangli Date: 2019-03-12 21:58:17 +0000
12-03-2019

Some additional removals of the hardcoded IPv4 literal 127.0.0.1. http://cr.openjdk.java.net/~chegar/8220083.additional/
12-03-2019