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

Reactor RetryOperator throws exception wrapped by RetryExceptionWrapper #816

Closed
nowaka opened this issue Jan 23, 2020 · 4 comments
Closed
Labels
Milestone

Comments

@nowaka
Copy link

nowaka commented Jan 23, 2020

Resilience4j version: 1.1.0 and 1.2.0
Java version: 8
Problem description:
I noticed that an original exception handled by RetryOperator is wrapped by RetryExceptionWrapper.
In my case the code is something like below:

public class BusinessService {
    private ExampleWebClient exampleWebClient;
    public Mono<String> doSomething() {
        return exampleWebClient.doSomething()
                .doOnError(BusinessException.class, e -> {
                    // log business exception
                })
                .doOnError(RetryExceptionWrapper.class, e -> {
                    // this block is executed but BusinessException is expected
                })
                .doOnError(e -> {
                    // log other exceptions
                });
    }
}

The above service calls a web client which is annotated with @Retry

@Retry(name = "exampleConfig")
public class ExampleWebClient {
    private WebClient webClient; // spring reactive web client
    public Mono<String> doSomething() {
        return webClient
                .get()
                .uri("/exampleEndpoint")
                .retrieve()
                .bodyToMono(String.class)
                .onErrorMap(WebClientResponseException.class, e -> new BusinessException());
    }
}

Not sure if this is expected behaviour but my understanding is that retry should be executed behind the scene and should not affect the reactor flow, i.e. removing or adding @Retry annotation should not change the type of exception received by the service class.

It may be worth mentioning that the BusinessException is added to ignoreExceptions.

Please let me know what do you think about this.
Thanks,
Adam.

@RobWin
Copy link
Member

RobWin commented Jan 23, 2020

Hi.
no, that's not the expected behavior. Usually it should unwrap the exception. I have a look at it.

@nowaka
Copy link
Author

nowaka commented Jan 23, 2020

Thanks for blitz fast answer.
Much appreciate it.

@alex-pumpkin
Copy link
Contributor

Should be fixed here #814

@RobWin RobWin added this to the 1.2.1 milestone Jan 29, 2020
@RobWin RobWin added the bug label Jan 29, 2020
@RobWin RobWin closed this as completed Jan 29, 2020
@nowaka-bookinggo
Copy link

Great stuff. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants