RFR: 8338452: (dc) DatagramChannelImpl.blockingReceive with timeout may block indefinitely if all datagrams blocked by SecurityManager
Alan Bateman
alanb at openjdk.org
Fri Aug 16 09:00:19 UTC 2024
A small regression from JDK-8338142 that arises with DatagramSocket.receive with a timeout and a SecurityManager, or when using a really small timeout (like 1ms). In these cases, the remaining time may be computed as negative which causes the receive to block indefinitely waiting for a datagram.
Timed receive requires timeout adjustment in two places (outer and inner loops). This complexity will go away when the SecurityManager implementation is removed. For now, I've kept the changes as small as possible so that the adjustment in the outer loop is only done when the datagram is denied by the security manager.
The test java/net/DatagramSocket/TimeoutWithSM.java exercises this code. It has failed at least once since JDK-8338142 was integrated.
-------------
Commit messages:
- Initial commit
Changes: https://git.openjdk.org/jdk/pull/20609/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20609&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8338452
Stats: 15 lines in 1 file changed: 11 ins; 4 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/20609.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20609/head:pull/20609
PR: https://git.openjdk.org/jdk/pull/20609
More information about the nio-dev
mailing list