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

Alan Bateman alanb at openjdk.java.net
Thu Oct 15 13:36:14 UTC 2020


On Thu, 15 Oct 2020 10:34:21 GMT, Conor Cleary <ccleary at openjdk.org> wrote:

> Occasional failures of this test have been observed. However it was unclear as to the precise nature of the failure due
> to minimal logging and multiple features of DatagramChannel being tested in one run. Another issue is that on failure
> of either a Writer or Reader thread, the thread that did not fail waits until the test itself times out.   To attempt
> to mitigate these factors, the test was modified in the following manner:
> - Additional logging was added to help locate future points of failure in the test.
> - On L95, guards were added to make sure the test for a DatagramChannel throwing an AlreadyConnectedException does not
>   end up using the same port as used for the connection on L86-87
> - `wait(CompletableFuture<?>... futures)` was implemented to throw a CompletionException if either the Reader or Writer
>   fails, rather than waiting for the test to time out.
> 
> Seeking review in particular on implementation of the `wait(CompletableFuture<?>... futures)` function. As it stands
> currently the wait function waits for one of the given futures completes exceptionally. If that doesnt happen, it will
> wait for _all_ futures to complete successfully.

test/jdk/java/nio/channels/DatagramChannel/Connect.java line 54:

> 52:
> 53:     static void invoke(Runnable reader, Runnable writer) throws CompletionException {
> 54:         CompletableFuture<Void> f1 = CompletableFuture.runAsync(writer);

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

test/jdk/java/nio/channels/DatagramChannel/Connect.java line 70:

> 68:                     });
> 69:                 });
> 70:         future.join();

Would ExecutorService invokeAny help you hear?

test/jdk/java/nio/channels/DatagramChannel/Connect.java line 153:

> 151:                 // Clean up
> 152:                 dc.disconnect();
> 153:                 dc.close();

Can you move the dc.close to the finally block so the socket is closed when there is an exception thrown.

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

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


More information about the nio-dev mailing list