Skip to content

Commit

Permalink
deprecated retryWhen usage substituted (Azure#17658)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Novikov <[email protected]>
  • Loading branch information
sergiusz-n and Sergey Novikov authored Nov 30, 2020
1 parent 62e60e5 commit 750e80b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import reactor.core.Exceptions;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

import java.time.Duration;
import java.util.Locale;
Expand Down Expand Up @@ -55,7 +56,7 @@ public static AmqpRetryPolicy getRetryPolicy(AmqpRetryOptions options) {
*/
public static <T> Flux<T> withRetry(Flux<T> source, Duration operationTimeout, AmqpRetryPolicy retryPolicy) {
return Flux.defer(() -> source.timeout(operationTimeout))
.retryWhen(errors -> retry(errors, retryPolicy));
.retryWhen(Retry.withThrowable(errors -> retry(errors, retryPolicy)));
}

/**
Expand All @@ -67,7 +68,7 @@ public static <T> Flux<T> withRetry(Flux<T> source, Duration operationTimeout, A
*/
public static <T> Mono<T> withRetry(Mono<T> source, Duration operationTimeout, AmqpRetryPolicy retryPolicy) {
return Mono.defer(() -> source.timeout(operationTimeout))
.retryWhen(errors -> retry(errors, retryPolicy));
.retryWhen(Retry.withThrowable(errors -> retry(errors, retryPolicy)));
}

private static Flux<Long> retry(Flux<Throwable> source, AmqpRetryPolicy retryPolicy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.azure.cosmos.implementation.directconnectivity.AddressSelector;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

import java.time.Duration;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -37,7 +38,7 @@ static public <T> Mono<T> executeRetry(Callable<Mono<T>> callbackMethod,
} catch (Exception e) {
return Mono.error(e);
}
}).retryWhen(RetryUtils.toRetryWhenFunc(retryPolicy));
}).retryWhen(Retry.withThrowable(RetryUtils.toRetryWhenFunc(retryPolicy)));
}

static public <T> Flux<T> fluxExecuteRetry(Callable<Flux<T>> callbackMethod, IRetryPolicy retryPolicy) {
Expand All @@ -48,7 +49,7 @@ static public <T> Flux<T> fluxExecuteRetry(Callable<Flux<T>> callbackMethod, IRe
} catch (Exception e) {
return Flux.error(e);
}
}).retryWhen(RetryUtils.toRetryWhenFunc(retryPolicy));
}).retryWhen(Retry.withThrowable(RetryUtils.toRetryWhenFunc(retryPolicy)));
}

static public <T> Mono<T> executeAsync(
Expand Down

0 comments on commit 750e80b

Please sign in to comment.