JDK-8319757 : java/nio/channels/DatagramChannel/InterruptibleOrNot.java failed: wrong exception thrown
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 17,21,22,23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-08
  • Updated: 2024-04-09
  • Resolved: 2024-01-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 22 JDK 23
21.0.4-oracleFixed 22Fixed 23 b05Fixed
Related Reports
Relates :  
Description
Test: java/nio/channels/DatagramChannel/InterruptibleOrNot.java

test InterruptibleOrNot.testInterruptBeforeInterruptibleReceive(): failure
java.lang.AssertionError: Expected ClosedByInterruptException to be thrown, but AsynchronousCloseException was thrown
	at org.testng.Assert.expectThrows(Assert.java:1724)
	at org.testng.Assert.assertThrows(Assert.java:1695)
	at InterruptibleOrNot.testInterruptBeforeReceive(InterruptibleOrNot.java:91)
	at InterruptibleOrNot.testInterruptBeforeInterruptibleReceive(InterruptibleOrNot.java:56)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
	at org.testng.TestRunner.privateRun(TestRunner.java:764)
	at org.testng.TestRunner.run(TestRunner.java:585)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
	at org.testng.SuiteRunner.run(SuiteRunner.java:286)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
	at org.testng.TestNG.runSuites(TestNG.java:1069)
	at org.testng.TestNG.run(TestNG.java:1037)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:102)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
	at java.base/java.lang.Thread.run(Thread.java:1570)
Caused by: java.nio.channels.AsynchronousCloseException
	at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:203)
	at java.base/sun.nio.ch.DatagramChannelImpl.endRead(DatagramChannelImpl.java:563)
	at java.base/sun.nio.ch.DatagramChannelImpl.receive(DatagramChannelImpl.java:603)
	at InterruptibleOrNot.lambda$testInterruptBeforeReceive$0(InterruptibleOrNot.java:91)
	at org.testng.Assert.expectThrows(Assert.java:1714)
	... 31 more
Comments
Fix request [21u] I backport this for parity with 21.0.4-oracle. No risk, only a test change. Clean backport. Test passes. SAP nightly testing passes.
05-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/324 Date: 2024-03-04 16:03:21 +0000
04-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk22/pull/69 Date: 2024-01-13 14:46:56 +0000
13-01-2024

Seems to be that way since original integration in JDK 15, JDK-8236246.
08-01-2024

Changeset: ace010b3 Author: Alan Bateman <alanb@openjdk.org> Date: 2024-01-06 08:52:27 +0000 URL: https://git.openjdk.org/jdk/commit/ace010b38a83e0c9b43aeeb6bc5c92d0886dc53f
06-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17251 Date: 2024-01-03 19:29:08 +0000
04-01-2024

AbstractInterruptibleChannel.end can't reliably distinguish the two cases where an interruptible I/O op is called with the interrupt status set and there is an async close around the same time. Both exceptions are allowed. The test should only schedule the async close when the channel is non-interruptible, scheduling an async close when the channel is interruptible is just complicating the test scenario.
24-12-2023

This is about calling receive with the interrupt status set and a racing async close. Need to think about whether spec clarifications are needed. The reason the test uses a 2s delay was to avoid the testing taking a long time for the non-interruptible case.
09-11-2023