Integrated: 8280113: (dc) DatagramSocket.receive does not always throw when the channel is closed
Alan Bateman
alanb at openjdk.org
Wed Feb 22 08:17:11 UTC 2023
On Mon, 20 Feb 2023 18:09:44 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> This is an issue with the async close of a DatagramChannel when a thread is blocked in its adaptor's receive method and the underlying socket is non-blocking. The async close causes poll to wakeup and the underlying receive to return 0 so it can't be distinguished from a receive of a zero-length datagram. The channel state needs to be checked to distinguish the two cases so that AsynchronousCloseException can be thrown if the channel has been closed. The bug goes back to JDK 14 when caching of sockaddr structured was introduced.
>
> The test case creates the conditions to exercise the case for both the timed and untimed receive. The bug report is the timed case, which receives two datagrams before attempting a timed receive. The harder case to test is the untimed case so the test uses a virtual thread to force the underlying socket to be non-blocking.
This pull request has now been integrated.
Changeset: b6ecca12
Author: Alan Bateman <alanb at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/b6ecca126846f9c53d554ff061cfe9b7b20a4d12
Stats: 135 lines in 2 files changed: 128 ins; 0 del; 7 mod
8280113: (dc) DatagramSocket.receive does not always throw when the channel is closed
Reviewed-by: jpai, dfuchs
-------------
PR: https://git.openjdk.org/jdk/pull/12674
More information about the nio-dev
mailing list