RFR: 8347756: Re-evaluate the java/net/DatagramSocket/InterruptibleDatagramSocket.java test

Jaikiran Pai jpai at openjdk.org
Wed Jan 15 13:25:44 UTC 2025


Can I please get a review of this test-only change which updates the `test/jdk/java/net/DatagramSocket/InterruptibleDatagramSocket.java` to match the specified behaviour of `DatagramSocket.receive()` method?

This test was introduced in Java 14 (https://bugs.openjdk.org/browse/JDK-8233018) and that version of Java through Java 18, behave differently when a DatagramSocket associated with a DatagramChannel, when blocked in a receive() is interrupted. In those versions, a `SocketException` gets thrown with `ClosedByInterruptException` as the cause of that `SocketException`. 

Starting Java 19, the specification of DatagramSocket.receive() has been updated to clarify the expectations of this scenario. Given those updates, the DatagramSocket.receive() is expected to throw a (top level) `ClosedByInterruptException` when associated with a `DatagramChannel`.

The change in this PR updates the test code to no longer expect a `SocketException` to contain the `ClosedByInterruptException`. With this change the test continues to pass both with platform threads as well as virtual threads. The test will no longer be skipped when the main() is launched through a virtual thread.

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

Commit messages:
 - 8347756: Re-evaluate the java/net/DatagramSocket/InterruptibleDatagramSocket.java test

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

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


More information about the net-dev mailing list