Java 14 - Change in InetSocketAddress.toString() behaviour seems to be causing issues
Jaikiran Pai
jai.forums2013 at gmail.com
Tue Mar 31 12:17:21 UTC 2020
Hello Alan,
On 30/03/20 1:31 pm, Alan Bateman wrote:
> On 28/03/2020 06:43, Jaikiran Pai wrote:
>>
>> There's an issue raised in Quarkus repo[1], where Apache Kafka
>> (embedded) no longer starts on Java 14. From what I can see the root
>> cause is this[2].
>>
>> JDK-8225499[3] changed the implementation (and even the javadoc) of
>> the InetSocketAddress.toString()
>>
> For the Quarkus/Kafka issue, do you know if it really needs to parse
> the String representation? Just curious why it doesn't use getHostString.
I don't have much knowledge about that library and unfortunately, the
git history on that file where this parsing is happening is very limited
and doesn't show the background about this code.
Either way, looking at the comment in that code which says:
// According to the Java 6 documentation, if the hostname is
// unresolved, then the string before the colon is the hostname.
it appears that it was added way back during Java 6 days, before the
InetSocketAddress.getHostString() API was introduced in Java 7.
I checked their release page[1] and the 3.4.x series (the one which has
this issue) was released just almost a year back. So I think it might
still be used by many. I'll anyway bring this up in their issue tracker
to get their inputs.
>
> As I think you've found, the spec/implementation change in Java SE 14
> has two parts.
>
> The change to surround an IPv6 literal address (and maybe the scope
> ID) in square brackets. Anything that parses a string that encodes an
> IP address and port, say the host component in a URI string, will have
> seen this already.
>
> The change to concatenate "/<unresolved>" to unresolved addresses. I
> think it's important to observe that an InetSocketAddress can be
> created with nonsensical input so it's easy to confuse code that
> parses the string representation, e.g. new
> InetSocketAddress("java.com/1.2.3.4", 80) creates an InetSocketAddress
> that is unresolved but its string representation (when run on JDK 13
> or older) would suggest otherwise.
Understood. Thank you!
[1] https://zookeeper.apache.org/releases.html
-Jaikiran
More information about the net-dev
mailing list