RFR: 8293696: java/nio/channels/DatagramChannel/SelectWhenRefused.java fails with "Unexpected wakeup" [v5]

Daniel Fuchs dfuchs at openjdk.org
Wed Nov 2 14:50:36 UTC 2022


On Wed, 2 Nov 2022 14:24:32 GMT, Darragh Clarke <duke 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.
>
> Darragh Clarke has updated the pull request incrementally with one additional commit since the last revision:
> 
>   changed checkUnexpectedWakeup

test/jdk/java/nio/channels/DatagramChannel/SelectWhenRefused.java line 97:

> 95:                             // our expected refuser port, cannot run just exit.
> 96:                             DatagramChannel.open().bind(refuser).close();
> 97:                             throw new RuntimeException("PortUnreachableException not raised");

maybe we could add `if (i < MAX_TRIES - 1) continue;` between line 96 and 97.

test/jdk/java/nio/channels/DatagramChannel/SelectWhenRefused.java line 99:

> 97:                             throw new RuntimeException("PortUnreachableException not raised");
> 98:                         } catch (PortUnreachableException pue) {
> 99:                             // expected

We could log that:

    System.out.println("Got expected " + pue);

test/jdk/java/nio/channels/DatagramChannel/SelectWhenRefused.java line 147:

> 145:                 ByteBuffer buf = ByteBuffer.allocate(100);
> 146:                 SocketAddress sa = datagramChannel.receive(buf);
> 147:                 String message = new String(buf.array());

You can't really use new String(buf.array()) here because you will read past the bytes that have been received. Also keep in mind that after receiving the position of the BB will be *at the end* of the message.

test/jdk/java/nio/channels/DatagramChannel/SelectWhenRefused.java line 154:

> 152:                 if (message.contains(GREETINGS_MESSAGE)) {
> 153:                     return true;
> 154:                 }

That's wrong. Remember: we want to ignore stray wake-ups, and a stray wake-up is defined as receiving a datagram that doesn't come from our own test.

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

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


More information about the nio-dev mailing list