Skip to content

Unresolved ipv6 InetSocketAddress is not parsed properly #74

@arsentiikaptsan

Description

@arsentiikaptsan

Hi!

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions