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

Alan Bateman alanb at openjdk.org
Sun Aug 24 07:49:59 UTC 2025


On Mon, 11 Aug 2025 19:06:29 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 incrementally with one additional commit since the last revision:
> 
>   8361495: Remove commented out code and low value print statement

test/jdk/java/nio/channels/FileChannel/ChannelInputStreamTest.java line 48:

> 46:             do {
> 47:                 Object obj;
> 48:                 if ((obj = q.poll()) != null) {

poll doesn't block so I assume this means the close test spins. Have you tried a blocking take?

test/jdk/java/nio/channels/FileChannel/ChannelInputStreamTest.java line 64:

> 62:     @Test
> 63:     public void available() throws IOException {
> 64:         var close = new ConcurrentLinkedQueue<Object>();

Maybe `static final Closeable STOP = () -> { };` would help here, it means mean the CLQ (maybe LTQ is better) doesn't need to be Object. Alternatively, the tests can just closeThread.interrupt.

test/jdk/java/nio/channels/FileChannel/ChannelInputStreamTest.java line 65:

> 63:     public void available() throws IOException {
> 64:         var close = new ConcurrentLinkedQueue<Object>();
> 65:         Thread closeThread = startCloseThread(close);

I think clear to put a try-finally after this, where the finally does the closeThread.join.

test/jdk/java/nio/channels/FileChannel/ChannelInputStreamTest.java line 89:

> 87:             } catch (Throwable t) {
> 88:                 close.offer(new Object());
> 89:                 throw new RuntimeException("Unexpected error", t);

This is junit test so I assume you can use "fail" rather than throw RuntimeException here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26435#discussion_r2296551442
PR Review Comment: https://git.openjdk.org/jdk/pull/26435#discussion_r2296552976
PR Review Comment: https://git.openjdk.org/jdk/pull/26435#discussion_r2296553656
PR Review Comment: https://git.openjdk.org/jdk/pull/26435#discussion_r2296553277


More information about the nio-dev mailing list