RFR: 8358764: (sc) SocketChannel.close when thread blocked in read causes connection to be reset (win)
Volkan Yazici
vyazici at openjdk.org
Wed Jun 11 08:12:28 UTC 2025
On Mon, 9 Jun 2025 19:17:16 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> On Windows, if a platform thread is blocked in SocketChannel.read, and another thread closes the channel, then Windows abruptly closes the connection (RST). In releases prior to JDK 11, the connection was shutdown for writing before closing so the connection was closed gracefully, an unexpected behavior change
>
> implCloseBlockingMode is changed to shutdown the connection for writing on Windows, no change in behavior for other platforms.
Verified that
1. Only on Windows, `implCloseNonBlockingMode()` disallows further writes prior to `tryClose()`
2. Tests stress the ill behavior reported
test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java line 166:
> 164: * {@code c} is the fully qualified class name and {@code m} is the method name.
> 165: */
> 166: private void onReach(Thread target, String location, Runnable action) {
Very sweet approach! 😋
-------------
Marked as reviewed by vyazici (Committer).
PR Review: https://git.openjdk.org/jdk/pull/25700#pullrequestreview-2916055853
PR Review Comment: https://git.openjdk.org/jdk/pull/25700#discussion_r2139466425
More information about the nio-dev
mailing list