RFR: 8264200: java/nio/channels/DatagramChannel/SRTest.java fails intermittently

Conor Cleary ccleary at openjdk.java.net
Tue Apr 6 12:27:09 UTC 2021


On Tue, 6 Apr 2021 11:22:04 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> ### Description
>> SRTest.java has been seen to fail intermittently in a similar manner to other recent failures in [DatagramChannel tests](https://github.com/openjdk/jdk/pull/679). With SRTest.java, these failures are associated with a number of issues listed below. Note that XReader refers to both ClassicReader and NioReader classes. Likewise for XWriter.
>> 
>> - Test is run in AgentVM mode.
>> - Receivers bind to wildcard/localhost which has been a source of instability.
>> - Sockets are not closed properly if an exception is thrown, even more of an issue due to test running in AgentVM mode.
>> - An XReader instance will wait forever to receive a `DatagramPacket` if an XSender has not sent one.
>> 
>> ### Fixes
>> To Address these issues, the following was done respective to the order of the Issues above:
>> - Test now runs with `testng/othervm` and uses its own thread pool. Note that the change to testng was not absolutely essential but means that if one test case fails the others will still be run which could provide useful information on why a failure occured.
>> - Receivers now bind to loopback address instead of localhost.
>> - XReader and XWriter classes implement `Autocloseable` and are declared within a try-with-resources block for each test case. As well as this, the test cases are now executed with `CompleteableFuture.allOf(futures)` such that if any Reader or Writer throws an exception during execution, the threads will exit in a safe manner and the exception concerned will be thrown (wrapped in a `CompletionException`).
>> - Test will now timeout with respect to timeout limit of Jtreg which is set to 20 seconds for this test. Note that this is given in the `@run` as `testng/othervm/timeout=20` tag in seconds. See Action Options in Jtreg docs [here](https://openjdk.java.net/jtreg/tag-spec.html).
>
> test/jdk/java/nio/channels/DatagramChannel/SRTest.java line 155:
> 
>> 153:         public void run() {
>> 154:             try {
>> 155:                 DatagramChannel dc = DatagramChannel.open();
> 
> This line needs to be removed since `dc` is now created in the constructor.

Dang, that's a bad one. Thank you for spotting! Didn't cause any test failures but of course very wrong.

> test/jdk/java/nio/channels/DatagramChannel/SRTest.java line 165:
> 
>> 163:                 dc.send(bb, isa);
>> 164:             } catch (Exception ex) {
>> 165:                 log.println("ClassicWriter [" + dc.socket().getLocalAddress() + "]");
> 
> This is not the `ClassicWriter` but the `NioWriter`

Same is true for the other classes, a fix was not included in the previous commit and will be in the next one

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

PR: https://git.openjdk.java.net/jdk/pull/3354


More information about the nio-dev mailing list