RFR: 8299827: Add resolved IP address in connection exception for sockets [v2]

Daniel Fuchs dfuchs at openjdk.org
Wed Jan 18 14:39:40 UTC 2023


On Wed, 18 Jan 2023 14:31:30 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>>> Hello @schmelter-sap, The javadoc of `String.join` states that it can throw a `NullPointerException` if any of the elements in `null`. As far as I can see, the `IOException` that may get thrown, probably isn't guaranteed to have a exception message, in which case this will run into a `NullPointerException`. Perhaps we should guard this code against that possibility?
>> 
>> On JDK 19: 
>> 
>> 
>> jshell> String.join(": ", null, "bar")
>> $3 ==> "null: bar"
>> 
>> 
>> 
>> As long as the delimiter is not null and the vararg array itself is not null then NPE will not be thrown...
>> 
>> https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/String.html#join(java.lang.CharSequence,java.lang.CharSequence...)
>
> @dfuch, you are right - it looks like the implementation of that API contradicts the javadoc. So I think it might end up being a CSR to update the javadoc to match the current implementation of `String.join()`. Given this, plus what Alan stated about the exception message being non-null in the context of this code, I think what Ralf currently has in this PR, is OK.

No the API documentation is indeed correct, it will throw if either the delimiter or the vararg array is null :-)
And yes - I agree that what Ralf has is OK. FWIW the previous code would also have inserted "null" if the message had been null.

-------------

PR: https://git.openjdk.org/jdk/pull/11961


More information about the net-dev mailing list