On Wed, 9 Aug 2023 07:46:58 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> The test uses this code to create a list of valid addresses for the localhost:
> 
>         String hostname = "localhost";
>         List<String> validAddresses = new LinkedList<>();
>         validAddresses.add(hostname);
>         Arrays.stream(InetAddress.getAllByName(hostname))
>                     .forEach(address -> 
> validAddresses.add(address.getHostAddress()));
> 
> It does not work properly if the custom name is set for the 127.0.01 via 
> /etc/hosts file. In that case, the address returned by the "startListen()" 
> will be "SomeCustomName:port", for example we can return it here:
> https://github.com/openjdk/jdk/blob/360f65d7b15b327e2f160c42f318945cc6548bda/src/jdk.jdi/share/classes/com/sun/tools/jdi/SocketTransportService.java#L82

Why do you think the hosts file should be fixed? it does not seem like the 
wrong configuration and the startListen() really return the  
"SomeCustomName:port". I can add a check to the test that the name returned by 
the getLocalHost could be mapped on 127.0.0.1.

Or I can skip all ip addresses for the getLocalHost() and uses the name only. 
But if it is not a test bug and the "loopback address" should always be used, 
then it seems a product bug.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15203#issuecomment-1673773524
PR Comment: https://git.openjdk.org/jdk/pull/15203#issuecomment-1673778075

Reply via email to