Prior to this patch, the test failed if the hostname returned by `startListening()` didn't match either the string "localhost" or the IP addresses associated with "localhost", but this is fragile. On machines where a reverse lookup on 127.0.0.1 returns a string other than localhost, the test fails, like in the following example:
>_ jdb -connect com.sun.jdi.SocketListen:port=50000 Listening at address: kubernetes.docker.internal:50000 ... >_ make test TEST=.../startlis001/TestDescription.java ... Test case #1: start listening the address kubernetes.docker.internal:49532 Expected addresses: localhost:null or 127.0.0.1:null or 0:0:0:0:0:0:0:1:null ... As a workaround, this patch uses `InetAddress.isLoopbackAddress()` on the hostname portion of the address that is being listened. Validated this patch on machines where the reverse lookup resolves to either "localhost" or a different string. --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - Fix localhost check in ListeningConnector.startListening test Changes: https://git.openjdk.org/jdk/pull/31744/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31744&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8387628 Stats: 49 lines in 1 file changed: 20 ins; 26 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/31744.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/31744/head:pull/31744 PR: https://git.openjdk.org/jdk/pull/31744
