RFR: 8329190: (ch) DatagramChannel.receive should throw ClosedChannelException when called on closed channel
Mark Sheppard
msheppar at openjdk.org
Tue Apr 16 15:35:00 UTC 2024
On Tue, 16 Apr 2024 14:04:37 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> Please oblige and review the following changes (provided by Alan Bateman) which addresses the issue outlined in
>> JDK-8329190: DatagramChannel.receive should throw ClosedChannelException when called on closed channel
>>
>> This ensures that a ClosedChannelException is consistently thrown from DatagramChannel send and receive methods, especially in the context of asynchronous closure and calling thread interruption.
>>
>> The change is to move the ensureOpen() method call, which checks that a channel has not been closed, to the start of read/write send/receive methods on the DatagramChannel
>>
>> The regression suites for jdk_nio and jdk_net and the JCK tests for api/java_nio api/java_net have been executed in repeat mode, multiple times, without any observed relevant failures.
>
> test/jdk/java/nio/channels/Channels/ClosedNetworkChannels.java line 64:
>
>> 62: fail();
>> 63: } catch (AsynchronousCloseException e) {
>> 64: fail(e + " thrown");
>
> I think for debugging any unexpected failures, it might be better to include the original exception too in the failure. Like:
>
> fail(e + " thrown", e);
yes, that is a reasonable suggestion. I will, if you don't mind, leave things as is, for the simple reason, I would need to submit such a change on repeat mode through MACH5, as it's for unexpected exceptions, and this can take 5/6 days for the job to get through MACH5, depending on resource availability, and I have gone through that cycle three times already for this fix
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18796#discussion_r1567570119
More information about the nio-dev
mailing list