RFR: 8358958: (aio) AsynchronousByteChannel.read/write should throw IAE if buffer is thread-confined [v2]
Jaikiran Pai
jpai at openjdk.org
Wed Jun 11 07:34:30 UTC 2025
On Tue, 10 Jun 2025 11:01:55 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> It's nonsensical to invoke read/write methods defined by the AsynchronousXXX channels with buffers that are views of memory segments allocated from a thread-confined arena.
>>
>> For AsynchronousSocketChannel, the current behavior is for the read/write methods to initiate an I/O operation that completes with an IOException and an IllegalStateException as cause. For AsynchronousFileChannel, the current behavior is for the read/write methods to initiate an I/O operation that never completes (a thread in the channel groups terminates with a WrongThreadException).
>>
>> The proposal is that the read/write methods reject, with IllegalArgumentException, any attempt to initiate as async I/O operation with a buffer from a thread-confined arena. IAE is already declared to be thrown for read-only buffers or attempting a positional read/write with a negative file position.
>>
>> The java/nio/channels/etc/MemorySegments.java test is updated to test AsynchronousSocketChannel and AsynchronousFileChannel with buffers from all arena kinds. The tests include attempts to close a shared arena while an I/O operation is in progress. For now, the testAsyncFileChannelXXX tests are disabled until they meet up with the changes in JDK-8357847 (pr/25531).
>
> Alan Bateman has updated the pull request incrementally with one additional commit since the last revision:
>
> Missing update to TestAsyncSocketChannels
`AsynchronousFileChannelImpl.java` requires a copyright year update.
test/jdk/java/nio/channels/etc/MemorySegments.java line 663:
> 661: Arena arena = arenaSupplier.get();
> 662:
> 663: Path file = Files.createTempFile(Path.of(""), "foo", ".dat");
Is the use of an empty `Path` instead of `Path.of(".")` intentional here? The documentation of `Path` states:
> Accessing a file using an <i>empty path</i> is equivalent to accessing the default directory of the file system.
Unlike the current working directory, I couldn't find the definition of default directory. Are they the same for the default filesystem?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25691#issuecomment-2961556065
PR Review Comment: https://git.openjdk.org/jdk/pull/25691#discussion_r2139417370
More information about the nio-dev
mailing list