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

Darragh Clarke duke at openjdk.org
Wed Nov 2 17:01:25 UTC 2022


On Wed, 2 Nov 2022 14:39:34 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

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

Adding `buf.flip()` between 146 and 147 should be enough to address this right?

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

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


More information about the nio-dev mailing list