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

Conor Cleary ccleary at openjdk.java.net
Tue Oct 20 11:45:18 UTC 2020


On Thu, 15 Oct 2020 11:25:34 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> Hi Conor,
> 
> Good work.
> Chris made a good remark to me privately. The test is running in same VM mode, and no longer waits for all threads
> (that is Actor & Reactor) to complete if one them throws an exception. We want, that - because we don't want the test
> to wait forever and timeout with no output (and no stack trace) if that happens. However, this may leave one of the
> Actor/Reactor in a state where it will live forever in the running agent VM, and may keep its DatagramChannel open -
> and that's bad.  One way to avoid that would be to make `Actor` & `Reactor` `Closeable`, and have them both create
> their `DatagramChannel` in their constructor.
> Then you could modify the `test` method in this way:
> 
> ```
> static void test() throws Exception {
>         try (Reactor r = new Reactor();
>                Actor a = new Actor(r.port());) {
>             invoke(a, r);
>         }
>     }
> ```
> 
> which would ensure that both DatagramChannels are closed when the test terminate, and would ensure that the other
> actor/reactor is unblocked and terminates too.

@dfuch Actor & Reactor now implement AutoCloseable and are instantiated in try-with-resource arguments.

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

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


More information about the nio-dev mailing list