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

Alan Bateman alanb at openjdk.org
Mon Oct 9 18:46:02 UTC 2023


On Mon, 9 Oct 2023 11:54:55 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:
> 
>   add missing quotation mark

So I think this version looks okay. We should probably rename the JBS issue and the PR as the change is no longer a handleSocketWithMessage function.

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

> 554:             NET_ThrowNew(env, WSAGetLastError(), "setsocketopt to block source");
> 555:         } else {
> 556:             NET_ThrowNew(env, WSAGetLastError(), "setsocketopt to unblock source");

I think this can be reduced to one message (block or unblock) source as it doesn't add value as the stack trace will make it very clear if a source-specific block or unblock op.

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

> 634:     u_long arg;
> 635:     if (ioctlsocket((SOCKET) fdval(env, fdo), FIONREAD, &arg) == SOCKET_ERROR) {
> 636:         NET_ThrowNew(env, WSAGetLastError(), "ioctlsocket");

Thanks for doing this, we should have removed the use of NET_SocketAvailable here a long time ago (same thing in the Unix code).

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

PR Review: https://git.openjdk.org/jdk/pull/16057#pullrequestreview-1665094335
PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1350683877
PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1350684981


More information about the nio-dev mailing list