RFR: 8247614: java/nio/channels/DatagramChannel/Connect.java timed out

Daniel Fuchs dfuchs at openjdk.java.net
Thu Oct 15 14:20:19 UTC 2020


On Thu, 15 Oct 2020 13:31:00 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> These run the reader and write in the common pool, are you sure that is what you want?

It shouldn't matter since there's no security manager. Are you worried that the common pool may not have enough threads
available to run these two tasks concurrently?

> test/jdk/java/nio/channels/DatagramChannel/Connect.java line 70:
> 
>> 68:                     });
>> 69:                 });
>> 70:         future.join();
> 
> Would ExecutorService invokeAny help you hear?

I don't think so - we kind of want to do the opposite: what we want is stop the test if any of the two tasks throws an
exception. The previous version of the test might have been blocked in the first call to `Thread::join` and not even
notice that the other thread had exited - which meant that the test would fail in timeout and not even report the
exception that made the other thread terminate. Here the allOf `future` will be completed as soon as: one task throws
an exception (thanks to the dependent action), or the two tasks complete successfully. There are many ways to do that -
but I find the solution that Conor came up with rather elegant.

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

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


More information about the nio-dev mailing list