Behavior of DatagramChannel vs ByteBuffers bound to MemorySessions

Alan Bateman Alan.Bateman at oracle.com
Sat Jun 8 19:35:58 UTC 2024



On 08/06/2024 16:55, Cleber Muramoto wrote:
> @Alan,
>
> Yes, Arenas can be closed at any time. Still, from my understanding, 
> this implicit restriction should only be imposed in code that does not 
> invoke JavaNioAccess::acquireSession explicitly, like in NioSocketImpl 
> or SocketChannelImpl.

All I/O operations defined by SocketChannel, DatagramSocket and 
FileChannel that read into a ByteBuffer or write from a ByteBuffer 
should be using acquire/releaseSession already. I checked all them and 
it's just the unconnected DatagramChannel send/receive that isn't using 
the right accessor to get the address. I should have spotted in when 
replying earlier. I have a test that exercises all the 16 I/O method 
with each of the 4 arena types. I'll create a bug for this.

NioSocketChannel is the SocketImpl for Socket/ServerSocket so it's 
byte[] rather than ByteBuffer.  SocketChannelImpl does use 
acquire/releaseSession for read/write methods on direct buffers. It 
exposes an adaptor view which the Socket API and thus byte[] rather than 
ByteBuffer.

-Alan


More information about the nio-dev mailing list