Bracket unresolved IPv6 host name in InetSocketAddress serialization - #6125
Bracket unresolved IPv6 host name in InetSocketAddress serialization#6125renechoi wants to merge 2 commits into
InetSocketAddress serialization#6125Conversation
|
Retargeting this to 2.18 branch would be great (oldest LTS). We require a CLA as described in https://github.com/FasterXML/jackson/blob/main/CONTRIBUTING.md#paperwork - could you provide a CLA based on this? |
a0aa31e to
9a5273d
Compare
|
Retargeted to The serializer is the same there, and and passes with it. Full suite on the retargeted branch (JDK 17, macOS): The change is the same four lines in the unresolved branch plus the regression test, now against the 2.x package layout ( On the CLA: understood, I am taking care of it and will send the signed copy to |
|
@renechoi Any issues with CLA? No urgency, just wanted to follow up. |
CI failed: 1 build failure in OSS-Fuzz integration due to package namespace mismatch where fuzzers reference Jackson 3.x (`tools.jackson.databind`) while building the Jackson 2.18 branch (`com.fasterxml.jackson.databind`).OverviewA single build failure occurred during OSS-Fuzz compilation where the fuzzer source files expect the Jackson 3.x package structure ( FailuresOSS-Fuzz Fuzzer Compilation Failure (confidence: high)
Summary
Code Review ✅ ApprovedBrackets unresolved IPv6 host names during Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
InetSocketAddressSerializerwriteshost + ":" + port. When the address is resolved it takes the host part fromInetAddress.toString()and brackets IPv6 literals, so a resolved address comes out as"[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443". When the address is unresolved there is noInetAddressat all, so it falls back togetHostName()and writes the literal bare:The trailing
:443is indistinguishable from another hextet, so the port is lost on the way back. This matters more since #5951, because deserialization now always produces unresolved addresses viaInetSocketAddress.createUnresolved(), so an IPv6 value read by Jackson no longer survives a Jackson round-trip:I noticed it while reading the
InetSocketAddresshandling inJDKFromStringDeserializerafter #6058/#5951, andJDKTypeSerializationTest.testInetSocketAddress()turned out to cover the unresolved form only for IPv4 and host names.Fix: in the unresolved branch, bracket the host name when it is an IPv6 literal, matching what the resolved branch already does. Host names that are already bracketed (which is what the deserializer stores for
"[...]:port"input) are left alone, so the value is never bracketed twice.Verification (JDK 21, macOS):
./mvnw test -Dtest=JDKTypeSerializationTest#testInetSocketAddressUnresolvedIPv6fails on 3.x without theInetSocketAddressSerializerchange (expected: <"[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443"> but was: <"2001:db8:85a3:8d3:1319:8a2e:370:7348:443">) and passes with it../mvnw -B -ff -ntp verify: BUILD SUCCESS,Tests run: 6171, Failures: 0, Errors: 0, Skipped: 1.The same code is on
2.x, and2.xdeserialization also creates unresolved addresses since #5951, so this likely belongs on an older line first. I opened it against3.xsince that is the default branch; I can open the equivalent PR against2.x(or whichever line you prefer) so it merges forward normally.