RFR: 8351458: (ch) Move preClose to UnixDispatcher

Alan Bateman alanb at openjdk.org
Tue Mar 11 07:34:53 UTC 2025


On Tue, 11 Mar 2025 04:42:50 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> src/java.base/share/classes/sun/nio/ch/NativeDispatcher.java line 82:
>> 
>>> 80:      */
>>> 81:     final void preClose(FileDescriptor fd, long reader, long writer) throws IOException {
>>> 82:         if (NativeThread.isVirtualThread(reader) || NativeThread.isVirtualThread(writer)) {
>> 
>> There used to be a `if (reader != 0 || writer != 0) {...}` check before doing any of this pre-close work, in `DatagramChannelImpl`. Is that no longer needed?
>
>> There used to be a if (reader != 0 || writer != 0) {...} check before doing any of this pre-close work, in DatagramChannelImpl. Is that no longer needed?
> 
> Looking at the implementation of `NativeThread.isNativeThread()` and `NativeThread.isVirtualThread()`, it already implicitly takes into account the `!= 0` check, so I guess the previous explicit checks before calling those methods was redundant.

Right, there are a several places where check for != 0 would be redundant.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23956#discussion_r1988576800


More information about the nio-dev mailing list