RFR: 8376290: SocketChannel.finishConnect() contains confusing "getsockopt" in exception message for a failed connect() on Windows

Alan Bateman alanb at openjdk.org
Mon Jan 26 10:38:12 UTC 2026


On Mon, 26 Jan 2026 09:54:41 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review of this change which proposes to remove the confusing "getsockopt" text from the exception reported on Windows when `SocketChannel.finishConnect()` raises an exception due to a failed `connect()`? 
> 
> This addresses https://bugs.openjdk.org/browse/JDK-8376290 and as noted in that issue, this looks like an oversight when changes were done for https://bugs.openjdk.org/browse/JDK-8317603. Prior to that, on older versions the exception reported on Windows was:
> 
> 
> java.net.ConnectException: Connection refused: no further information
> 
> 
> With the current proposed changes in this PR, the exception will now be `java.net.ConnectException: Connection refused` which matches what we report on *nix platforms.
> 
> A new jtreg test has been added to reproduce the original text and verify the change. tier1, tier2 and tier3 continue to pass with this change.

src/java.base/windows/native/libnet/net_util_md.c line 165:

> 163:             jio_snprintf(fullMsg, sizeof(fullMsg), "%s: %s",
> 164:                              (char *)winsock_errors[i].errString, msg);
> 165:         }

Can you fix up the alignment of the 3rd param, it's a bit messed up with the edits.

test/jdk/java/nio/channels/Selector/FailedConnect.java line 49:

> 47:  * @run junit ${test.main.class}
> 48:  */
> 49: class FailedConnect {

Maybe rename to ConnectionRefusedMessage as this isn't a unit test for connect failing?

test/jdk/java/nio/channels/Selector/FailedConnect.java line 76:

> 74:             System.err.println("establishing connection to " + destAddr);
> 75:             boolean connected = sc.connect(destAddr);
> 76:             assertFalse(connected, "unexpectedly connected to " + destAddr);

I think the test will have to retry if "connected" returns true as it's too easy to have interference between tests on the same host.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29409#discussion_r2727097372
PR Review Comment: https://git.openjdk.org/jdk/pull/29409#discussion_r2727105812
PR Review Comment: https://git.openjdk.org/jdk/pull/29409#discussion_r2727099761


More information about the net-dev mailing list