> 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).
Ashay Rane has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision: - Merge branch 'master' into JDK-8387628-localhost - Fix localhost check in ListeningConnector.startListening test 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. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/31744/files - new: https://git.openjdk.org/jdk/pull/31744/files/ce6af252..06ae46c4 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=31744&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31744&range=00-01 Stats: 1620 lines in 113 files changed: 765 ins; 589 del; 266 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
