Fixes ipv6 formatting in specific scenario

Use getHostAddress() when getHostName() might return a host name which
doesn't need brackets for formatting.

Fixes gh-807
This commit is contained in:
fanjiaqi
2023-01-18 11:44:26 +08:00
committed by spencergibb
parent 6378b72526
commit 3447b576ff

View File

@@ -55,7 +55,7 @@ public final class ConsulServerUtils {
try {
InetAddress inetAdr = InetAddress.getByName(address);
if (inetAdr instanceof Inet6Address) {
return "[" + inetAdr.getHostName() + "]";
return "[" + inetAdr.getHostAddress() + "]";
}
return address;
}