RFR: 8293696: java/nio/channels/DatagramChannel/SelectWhenRefused.java fails with "Unexpected wakeup"
Daniel Fuchs
dfuchs at openjdk.org
Tue Oct 25 14:19:42 UTC 2022
On Tue, 25 Oct 2022 13:01:11 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Added logging to SelectWhenRefused for an intermittent failure caused by unexpected wakeups, this includes trying to receive data if there is any available to identify where it is coming from.
>>
>> I also set the test to run in othervm mode which should reduce the chances of this failure happening in the first place.
>
> test/jdk/java/nio/channels/DatagramChannel/SelectWhenRefused.java line 114:
>
>> 112: if (!key.isValid() || !key.isReadable()) {
>> 113: System.out.println("Invalid or unreadable key: " + key);
>> 114: return;
>
> The loop over the selection keys and checking if valid or readable doesn't make sense here. Maybe that can be just removed. If you really want to print out the selection key then save it at L52 so that you have the SelectionKey to print.
Since we have no idea of what is going on it's fine to loop over the set of selected keys - even if it should contain at most one entry. But if it contains a key that is either not valid or not readable we should continue after printing it, not return.
> test/jdk/java/nio/channels/DatagramChannel/SelectWhenRefused.java line 119:
>
>> 117: System.out.println("Attempting to read datagram from key: " + key);
>> 118: ByteBuffer buf = ByteBuffer.allocate(100);
>> 119: SocketAddress sa = dc.receive(buf);
>
> The datagram channel is configured non-blocking and there may not be a datagram to receive, therefore sa may be null and has to be checked here.
@AlanBateman If we reach here the key is both valid and readable so shouldn't there be something to receive, even if the channel is non-blocking?
-------------
PR: https://git.openjdk.org/jdk/pull/10851
More information about the nio-dev
mailing list