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

Alan Bateman alanb at openjdk.org
Thu Jan 4 12:33:32 UTC 2024


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.

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

Commit messages:
 - Add asserts to test that channel is closed
 - Speed up test
 - Initial commit

Changes: https://git.openjdk.org/jdk/pull/17251/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17251&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8319757
  Stats: 160 lines in 1 file changed: 54 ins; 29 del; 77 mod
  Patch: https://git.openjdk.org/jdk/pull/17251.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17251/head:pull/17251

PR: https://git.openjdk.org/jdk/pull/17251


More information about the nio-dev mailing list