You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a problem, when I tried to create HostName from unresolved ipv6 InetSocketAddress. Here is a snippet:
var address = InetSocketAddress.createUnresolved("::1", 8080);
var hostName = new HostName(address);
System.out.println("Is valid: " + hostName.isValid());
System.out.println("Host: " + hostName.getHost());
System.out.println("Port: " + hostName.getPort());
System.out.println("HostName as string: " + hostName.toNormalizedString());
Output:
Is valid: true
Host: ::1:8080
Port: null
HostName as string: [0:0:0:0:0:0:1:8080]
Apparently, HostName does not properly parse port in this case. However if I create address with: new InetSocketAddress("::1", 8080), everything is fine and I get [0:0:0:0:0:0:0:1]:8080 as the result.
The text was updated successfully, but these errors were encountered:
To trigger this bug you need an IPv6 compressed address like "::1", and you need to create the InetSocketAddress with InetSocketAddress.createUnresolved. If both those happen, then the port will become the last part of the address.
A fix for this will go into future releases.
In the meantime, the work-around choices would be:
Use the constructors for InetSocketAddress and not InetSocketAddress.createUnresolved, as you have shown.
Use the following code to construct the HostName from an InetSocketAddress. This code allows you to continue using InetSocketAddress.createUnresolved:
Hi!
I ran into a problem, when I tried to create HostName from unresolved ipv6 InetSocketAddress. Here is a snippet:
Output:
Apparently, HostName does not properly parse port in this case. However if I create address with:
new InetSocketAddress("::1", 8080)
, everything is fine and I get [0:0:0:0:0:0:0:1]:8080 as the result.The text was updated successfully, but these errors were encountered: