RFR: JDK-8317603: Improve exception messages thrown by sun.nio.ch.Net native methods (win) [v7]

Alan Bateman alanb at openjdk.org
Tue Oct 10 09:48:15 UTC 2023


On Tue, 10 Oct 2023 09:24:37 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:
> 
>   adjust some messages

Marked as reviewed by alanb (Reviewer).

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

> 534:         int opt = (join) ? MCAST_JOIN_SOURCE_GROUP : MCAST_LEAVE_SOURCE_GROUP;
> 535:         n = setGroupSourceReqOption(env, fdo, opt, group, index, source);
> 536: 

I assume this blank line isn't needed now.

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

> 550:     int n = setGroupSourceReqOption(env, fdo, opt, group, index, source);
> 551:     if (n == SOCKET_ERROR) {
> 552:         NET_ThrowNew(env, WSAGetLastError(), "setsocketopt to block or unblock source");

This message is okay although it can be reduced to "setsockopt" to be consistent with the others. If source filtering is used then the stack trace will be very clear if a source address is being blocked or unblocked.

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

PR Review: https://git.openjdk.org/jdk/pull/16057#pullrequestreview-1667076159
PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1352035707
PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1352039763


More information about the nio-dev mailing list