On Tue, 7 Dec 2021 12:29:09 GMT, Alan Bateman <al...@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.

LGTM. I agree, setting the flag before attempting to close the impl is a better 
behavior.

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

Marked as reviewed by dfuchs (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6741

Reply via email to