From 3e93881cf48e118a2cddad08a0f1472dcbf52fb1 Mon Sep 17 00:00:00 2001 From: Andrii Serkes Date: Fri, 23 Dec 2022 09:52:07 +0100 Subject: [PATCH] 5409 duration timeout (#5709) add methods that use Duration --- .../io/helidon/common/reactive/Awaitable.java | 4 ++- .../io/helidon/common/reactive/IoMulti.java | 16 +++++++++- .../io/helidon/config/FileSystemWatcher.java | 29 ++++++++++++++++++- .../health/MicrostreamHealthCheck.java | 18 +++++++++++- .../client/narayana/NarayanaClient.java | 13 ++++----- .../coordinator/client/CoordinatorClient.java | 15 +++++++++- .../dbclient/health/DbClientHealthCheck.java | 15 ++++++++++ .../reactive/health/HealthSupport.java | 19 ++++++++++-- .../helidon/reactive/webclient/WebClient.java | 4 +++ .../webclient/WebClientRequestBuilder.java | 21 ++++++++++++++ .../WebClientRequestBuilderImpl.java | 12 ++++++++ 11 files changed, 150 insertions(+), 16 deletions(-) diff --git a/common/reactive/src/main/java/io/helidon/common/reactive/Awaitable.java b/common/reactive/src/main/java/io/helidon/common/reactive/Awaitable.java index 5b2a0e606ea..3a3c621b740 100644 --- a/common/reactive/src/main/java/io/helidon/common/reactive/Awaitable.java +++ b/common/reactive/src/main/java/io/helidon/common/reactive/Awaitable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,9 @@ default T await() { * @throws java.util.concurrent.CancellationException if this future was cancelled * @throws java.util.concurrent.CompletionException if this future completed exceptionally, * was interrupted while waiting or the wait timed out + * @deprecated use {@link #await(Duration)} instead */ + @Deprecated(since = "4.0.0") default T await(long timeout, TimeUnit unit) { try { return this.toCompletableFuture().get(timeout, unit); diff --git a/common/reactive/src/main/java/io/helidon/common/reactive/IoMulti.java b/common/reactive/src/main/java/io/helidon/common/reactive/IoMulti.java index 11c1bdf0cd3..67f9502f083 100644 --- a/common/reactive/src/main/java/io/helidon/common/reactive/IoMulti.java +++ b/common/reactive/src/main/java/io/helidon/common/reactive/IoMulti.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. + * Copyright (c) 2020, 2022 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -446,12 +446,26 @@ private OutputStreamMultiBuilder() { * @param timeout the maximum time to block * @param unit the time unit of the timeout argument * @return this builder + * @deprecated use {@link #timeout(Duration)} instead */ + @Deprecated(since = "4.0.0") public OutputStreamMultiBuilder timeout(long timeout, TimeUnit unit) { this.timeout = Duration.of(timeout, unit.toChronoUnit()); return this; } + /** + * Set max timeout for which is allowed to block write methods, + * in case there is no demand from downstream. + * + * @param timeout the maximum time to block + * @return this builder + */ + public OutputStreamMultiBuilder timeout(Duration timeout) { + this.timeout = timeout; + return this; + } + /** * Callback executed when request signal from downstream arrive. *