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

Improve Javadoc for setThrowLastExceptionOnExhausted of RetryTemplate #137

Closed
fabriziocucci opened this issue Dec 9, 2018 · 4 comments
Closed
Assignees
Milestone

Comments

@fabriziocucci
Copy link

Description

As already reported here, I was too a bit surprised to discover that throwLastExceptionOnExhausted has no effect on stateless retries.

I'm not sure I fully understand the logic behind the current behaviour but it would be nice to, at very least, fix the current javadoc by explicitly mentioning that.

@dsyer
Copy link
Member

dsyer commented Dec 15, 2018

A stateless retry always throw the last exception (if it is an Exception) I think. Isn't that kind of what you want if you are setting that flag anyway?

@fabriziocucci
Copy link
Author

@dsyer thanks for your reply.

The current behavior for stateless retry seems to be:

  • throwLastExceptionOnExhausted=true -> last exception is thrown
  • throwLastExceptionOnExhausted=false -> last exception is thrown

So, in any case, the last exception is always thrown and this means that the flag has no effect on stateless retries.

From a user prospective, I would have somehow expected:
throwLastExceptionOnExhausted=false -> ExhaustedRetryException is thrown.

@dsyer
Copy link
Member

dsyer commented Dec 15, 2018

I see what you mean. I'm not sure why you would want to set it to false in that case (that's the default anyway). Do you have an actual use case. If not, and this is really just a nitpick about the javadocs, then feel free to send a pull request clarifying the situation/

@Rajh
Copy link

Rajh commented Oct 18, 2019

Hello,
I actually have a case where I wanted ExhaustedRetryException to be thrown but couldn't understand why it wasn't.
I created an unique RetryTemplate which was called several times, and I wanted to catch on top of them if my exception came from a RetryTemplate or not.

Would it be possible to make this option works on stateless retry too ?

I'm actually throwing an exception wrapper from a listener as a workaround

@artembilan artembilan added this to the 2.0.6 milestone May 13, 2024
@artembilan artembilan self-assigned this May 13, 2024
natedanner pushed a commit to natedanner/spring-projects__spring-retry that referenced this issue May 20, 2024
…Exhausted()` JavaDocs

Fixes: spring-projects#137

* Fix couple code smells for arrays in the `RetryTemplate`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants