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

Add rethrow flag #265

Closed
wants to merge 6 commits into from
Closed

Conversation

ttulka
Copy link
Contributor

@ttulka ttulka commented Jan 26, 2022

this implements #264

@pivotal-cla
Copy link

@ttulka Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@ttulka Thank you for signing the Contributor License Agreement!

@ttulka ttulka changed the title #264 add rethrowNonRetryable flag Add rethrowNonRetryable flag Jan 26, 2022
@ttulka ttulka changed the title Add rethrowNonRetryable flag Add rethrow flag Jan 27, 2022
@ttulka
Copy link
Contributor Author

ttulka commented Mar 25, 2022

@garyrussell Any updates on this, please?

@garyrussell
Copy link
Contributor

Sorry; haven't had a chance to look at it yet; will try this week.

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; there are a couple of issues; also the Copyright for all affected files needs to be changed to 2022.

}

}

/**
* Delegates to an exception classifier.
* @param ex
* @return true if this exception or its ancestors have been registered as retryable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need @since 1.3.3 now that it is public.

context.setAttribute(RetryContext.EXHAUSTED, true);
if (state != null && !context.hasAttribute(GLOBAL_STATE)) {
this.retryContextCache.remove(state.getKey());
}
if (this.throwLastExceptionOnExhausted && retryPolicy instanceof SimpleRetryPolicy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a behavior change and could break existing projects that expect the recovery callback to be invoked for all exceptions. I think we need a new boolean noRecoveryForNotRetryable or similar.

Copy link
Contributor Author

@ttulka ttulka Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garyrussell throwLastExceptionOnExhausted is true only if Retryable.rethrow is true, which is false per default. So, all the old code will have throwLastExceptionOnExhausted set to false and this new if branch will be skipped.

Could you please collaborate more if I miss something? Thanks!

Copy link
Contributor

@garyrussell garyrussell Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ttulka Sorry for the delay. The problem is for users of the RetryTemplate (those not using @Retryable, which is very common).

If an existing application is using the template with throwLastExceptionOnExhausted then the recovery callback is still invoked for a not-retryable exception.

With your change, it will no longer be called; hence the new behavior needs to be controlled by a new property on the template rather than overloading the existing property to have 2 meanings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garyrussell Thanks for clearing things up! I have committed the changes with the new flag.

@garyrussell
Copy link
Contributor

@ttulka Thanks for the contribution!

Merged as ec245fd and added a few docs 0c1fa82

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

Successfully merging this pull request may close these issues.

3 participants