RFR: 8319757: java/nio/channels/DatagramChannel/InterruptibleOrNot.java failed: wrong exception thrown [v2]

Jaikiran Pai jpai at openjdk.org
Fri Jan 5 16:09:22 UTC 2024


On Thu, 4 Jan 2024 12:54:34 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> InterruptibleOrNot.testInterruptBeforeInterruptibleReceive has failed a few times. It calls DatagramChannel.receive with the interrupt status set and expects ClosedByInterruptException to be thrown. The shared part of the test is also used for the non-interruptible scenario which needs a delayed close to ensure the thread calling receive wakes up. The 2s delay is not sufficient and thus it's possible for the async close to beat the detection of the interrupt status. This leads to AsynchronousCloseException instead of the expected ClosedByInterruptException.
>> 
>> The test is re-worked to split the interruptible and non-interruptible tests. The test is also changed to drop the delayed interrupt/close and instead use a thread to poll under the target thread is in DatagramChannel.receive. The overall test is simpler. I changed it to be a JUnit test, that part is only a few lines of changes.
>
> Alan Bateman has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix comment in testInterruptDuringUninterruptibleReceive

The test changes look OK to me.

Given that these are unconnected DatagramChannels, do you think this test is susceptible to receiving unexpected packets (in CI environments) and can run into intermittent failures (receive completing successfully before being interrupted)? Would making them connected (to a test specific address that never sends anything) improve the situation or would that then take a different code path than what this test intends to test?

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

Marked as reviewed by jpai (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17251#pullrequestreview-1806240526


More information about the nio-dev mailing list