Integrated: 8278339: ServerSocket::isClosed may return false after accept throws
Alan Bateman
alanb at openjdk.java.net
Tue Dec 7 14:26:26 UTC 2021
On Tue, 7 Dec 2021 12:29:09 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> JDK-8278270 introduces a small regression. If a ServerSocket is closed while another thread is blocked in the accept method then the other thread may observe isClosed returning false, i.e. code may catch IOException and check isClosed before the "closed" flag gets to true.
>
> I've changed the close method to set the "closed" flag before closing the underlying impl. This is consistent with the network channels and also consistent with async close where the close completes on the thread that was blocked in accept. The change also prevents re-attempting the underlying impl in the unlikely event that it fails(an area that is completed unspecified). Overall I think this is preferable to have add synchronization to isClosed.
This pull request has now been integrated.
Changeset: 69d8669f
Author: Alan Bateman <alanb at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/69d8669fb3f1e4db2fbb3366a1349dd0285f5b0f
Stats: 93 lines in 2 files changed: 85 ins; 7 del; 1 mod
8278339: ServerSocket::isClosed may return false after accept throws
Reviewed-by: dfuchs
-------------
PR: https://git.openjdk.java.net/jdk/pull/6741
More information about the net-dev
mailing list