RFR: 8338452: (dc) DatagramChannelImpl.blockingReceive with timeout may block indefinitely if all datagrams blocked by SecurityManager

Daniel Fuchs dfuchs at openjdk.org
Fri Aug 16 10:03:49 UTC 2024


On Fri, 16 Aug 2024 08:27:41 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> 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.

OK - looks reasonable

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

Marked as reviewed by dfuchs (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20609#pullrequestreview-2242374344


More information about the nio-dev mailing list