RFR: 8293696: java/nio/channels/DatagramChannel/SelectWhenRefused.java fails with "Unexpected wakeup" [v4]
Alan Bateman
alanb at openjdk.org
Tue Nov 1 19:09:32 UTC 2022
On Tue, 1 Nov 2022 18:45:41 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> It make no sense because it puts the dc.receive into the loop that is examining the keys. If you really want to look at the state of the key then capture the result of the register method so you can print it out after the selection operation.
>
> I see. So you advise to pass the single key we obtained when registering the channel, to the method, rather than the selected key set. That's OK with me too.
The method need only be passed one parameter, the DatagramChannel or the SelectionKey (key::channel will give you the channel). Right now it is confused because it wants to loop over all selected keys but it doesn't use the key's channel for the receive method. If I were changing this test then I think I would just pass it the DatagramChannel as the selection key is not really interesting. I think I would also change it to check if sa (the sender) is null so that it doesn't print a confusing message when no datagram has been received.
-------------
PR: https://git.openjdk.org/jdk/pull/10851
More information about the nio-dev
mailing list