Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated retryWhen usage substituted #17658

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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