[jdk21u-dev] RFR: 8358764: (sc) SocketChannel.close when thread blocked in read causes connection to be reset (win)

Severin Gehwolf sgehwolf at openjdk.org
Mon Sep 1 15:28:01 UTC 2025


Please review this unclean backport of JDK-8358764. This is for partity with 21.0.9-oracle. The backport is not clean for the following reasons:

- Usage of `StableValue` in the original patch. I've replaced this with a static variable in class `Net`. Similar to `FAST_LOOPBACK`.
- Context differences in `SocketChannelImpl.java`, method `implCloseBlockingMode()`. JDK-8351458, "(ch) Move preClose to UnixDispatcher" is not in JDK 21u.
- Test `PeerReadsAfterAsyncClose` needed an adaptation since the match on the stack trace is wrong for JDK 21. It should be `sun.nio.ch.SocketChannelImpl.read` instead of `sun.nio.ch.SocketChannelImpl.implRead` (in JDK head). The reason for this seems to be "JDK-8308995: Update Network IO JFR events to be static mirror events" (JDK 22+).

Other than that it's a fairly straight-forward port.

**Testing:**

- [x] jdk_net, jdk_nio on Linux x86_64
- [x] New regression test on Windows without the product fix (fails) and passes with the product fix. The test passes on Linux with/without the product fix so isn't indicative there (as it should since it's a Windows fix).
- [x] GHA 

Thoughts?

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

Commit messages:
 - Backport e5196fc24d2ec9e581af7803ac47036111fee029

Changes: https://git.openjdk.org/jdk21u-dev/pull/2137/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk21u-dev&pr=2137&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8358764
  Stats: 246 lines in 5 files changed: 229 ins; 1 del; 16 mod
  Patch: https://git.openjdk.org/jdk21u-dev/pull/2137.diff
  Fetch: git fetch https://git.openjdk.org/jdk21u-dev.git pull/2137/head:pull/2137

PR: https://git.openjdk.org/jdk21u-dev/pull/2137


More information about the jdk-updates-dev mailing list