[RFR] 8224645: Test java/nio/channels/DatagramChannel/BasicMulticastTests.java fails with NoSuchElementException

Daniel Fuchs daniel.fuchs at oracle.com
Mon May 27 11:02:56 UTC 2019


[adding nio-dev]

On 23/05/2019 18:19, Arthur Eubanks wrote:
> bug: https://bugs.openjdk.java.net/browse/JDK-8224645
> webrev: http://cr.openjdk.java.net/~aeubanks/8224645/webrev.00/


Hi Arthur,

I would suggest three things:

1. replace `if (....hasNext()) {` with `while (....hasNext()) {`
2. add a counter, and increment it at the end of the `while` block
    to count how many interfaces where successfully tested
3. In the end, just before exiting main, check the value of
    the counter with something like:


```
         if (count == 1) {
             System.out.println("Tested only " + count
                            + " multicast interface");
         } else if (count > 1) {
             System.out.println("Tested " + count
                            + " multicast interfaces");
         } else {
             NetworkConfiguration.printSystemConfiguration(System.err);
             throw new SkippedException(
                       "No multicast interfaces found!");
         }
```

best regards,

-- daniel


More information about the nio-dev mailing list