RFR: JDK-8317603: provide handleSocketErrorWithMessage in windows Net.c for extended exception messages [v2]

Daniel Jeliński djelinski at openjdk.org
Fri Oct 6 09:46:00 UTC 2023


On Fri, 6 Oct 2023 07:21:13 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> On Windows, we miss a handleSocketErrorWithMessage function that provides an additional message showing what went wrong in the Net.c coding.  On Unix we have this function. 
>> This leads sometimes to exceptions like
>> 
>> MSG RTE: javax.naming.CommunicationException: example.com:1234 [Root exception is java.net.ConnectException: Connection timed out: no further information]
>> 
>> see https://bugs.openjdk.org/browse/JDK-8317307
>> 
>> It would be better to have a message explaining the reason instead of "no further information" .
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
> 
>   switch to NET_ThrowNew

src/java.base/windows/native/libnio/ch/Net.c line 732:

> 730:             }
> 731:         } else if (optError != NO_ERROR) {
> 732:             NET_ThrowNew(env, optError, "getsockopt");

This is not a `getsockopt` error, and using `"getsockopt"` here will make errors thrown here indistinguishable from errors thrown a few lines above. Can we use a different text?
The errors here will usually be the result of async connect, but I'm not sure if that's guaranteed; `SO_ERROR` would probably be the safest choice, but it doesn't look pretty. I guess that's one of the places where "no further information" actually makes sense.
Other than this, LGTM.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1348390145


More information about the nio-dev mailing list