(reported by @renechoi in #6125 â fix to be implemented independently as the original PR was closed without a CLA)
InetSocketAddressSerializer writes values as host + ":" + port. For a resolved address it takes the host part from InetAddress.toString() and brackets IPv6 literals, so output looks like "[2001:db8::1]:443". For an unresolved address there is no InetAddress, so it falls back to getHostName() and writes an IPv6 literal bare:
InetSocketAddress.createUnresolved("2001:db8::1", 443)
// serialized as "2001:db8::1:443"
The trailing :443 is indistinguishable from another hextet, so the port cannot be recovered on deserialization.
This has become more visible since #5951: deserialization now always constructs unresolved addresses via InetSocketAddress.createUnresolved(), so a bare IPv6 address value read by Jackson no longer survives a round-trip â on re-serialization the port gets appended bare, and the next read absorbs it into the host name.
Expected: the unresolved branch should bracket IPv6 literals the same way the resolved branch already does, e.g. "[2001:db8::1]:443". Host names that are already bracketed (which is what the deserializer stores for "[...]:port" input) must not be bracketed twice.
Applies to 2.x (2.18+) and 3.x; existing JDKTypeSerializationTest.testInetSocketAddress() covers the unresolved form only for IPv4 and host names.
(reported by @renechoi in #6125 â fix to be implemented independently as the original PR was closed without a CLA)
InetSocketAddressSerializerwrites values ashost + ":" + port. For a resolved address it takes the host part fromInetAddress.toString()and brackets IPv6 literals, so output looks like"[2001:db8::1]:443". For an unresolved address there is noInetAddress, so it falls back togetHostName()and writes an IPv6 literal bare:The trailing
:443is indistinguishable from another hextet, so the port cannot be recovered on deserialization.This has become more visible since #5951: deserialization now always constructs unresolved addresses via
InetSocketAddress.createUnresolved(), so a bare IPv6 address value read by Jackson no longer survives a round-trip â on re-serialization the port gets appended bare, and the next read absorbs it into the host name.Expected: the unresolved branch should bracket IPv6 literals the same way the resolved branch already does, e.g.
"[2001:db8::1]:443". Host names that are already bracketed (which is what the deserializer stores for"[...]:port"input) must not be bracketed twice.Applies to 2.x (2.18+) and 3.x; existing
JDKTypeSerializationTest.testInetSocketAddress()covers the unresolved form only for IPv4 and host names.