RFR: 8361495: (fc) Async close of streams connected to uninterruptible FileChannel doesn't throw AsynchronousCloseException in all cases [v5]

Alan Bateman alanb at openjdk.org
Tue Aug 26 06:47:36 UTC 2025


On Mon, 25 Aug 2025 23:13:28 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Throw `AsynchronousCloseException` from `FileChannelImpl` methods if the channel is uninterruptible and was closed before the method (operation) could complete.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - 8361495: Rename test and improve as suggested
>  - Merge
>  - 8361495: Remove commented out code and low value print statement
>  - 8361495: Add read and write tests and convert to JUnit 5
>  - 8361495: Clean up initial test
>  - 8361495: (fc) Async close of streams connected to uninterruptible FileChannel doesn't throw AsynchronousCloseException in all cases

test/jdk/java/nio/channels/Channels/AsyncCloseStreams.java line 52:

> 50:                 try {
> 51:                     Closeable c;
> 52:                     if ((c = q.take()) != null) {

The loop could be simplified to use `while ((c = q.take()) != STOP)`.

test/jdk/java/nio/channels/Channels/AsyncCloseStreams.java line 99:

> 97:                 }
> 98:             } while (true);
> 99:         } finally {

If the finally blocks were to offer the STOP element then it would remove it from the 3 exit paths and make it more robust.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26435#discussion_r2299951671
PR Review Comment: https://git.openjdk.org/jdk/pull/26435#discussion_r2299954521


More information about the nio-dev mailing list