RFR: 8372958: SocketInputStream.read throws SocketException instead of returning -1 when input shutdown

Daniel Jeliński djelinski at openjdk.org
Wed Dec 3 10:47:40 UTC 2025


On Wed, 3 Dec 2025 07:47:40 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> Invoking Socket.shutdownInput at around the same time that another thread is attempts to read or is blocked in read on the same Socket has always been problematic on Windows. For virtual threads, the read may fail with a SocketException exception like "A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call". The change proposed here to change the SocketImpl to handle the async shutdownInput and cause read to return -1. 
> 
> Tests for async shutdownInput and shutdownOutput are added to BlockingSocketsOps. Some minor drive by clean-up to use a value source for the tests that exercise both untimed and timed cases. Similar cleanup in BlockingChannelOps as it tests the socket adapters doing both untimed and timed reads. The existing test for async shutdown with platform threads is migrated to JUnit as part of the change.
> 
> Testing: tier1 + tier2, test repeat runs of the modified tests to ensure they are stable.

Marked as reviewed by djelinski (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/28626#pullrequestreview-3534415275


More information about the nio-dev mailing list