Overview
Spring Framework 7.0.0-M9
Spring Retry's RetryTemplateBuilder has a traversingCauses() option, allowing setups like this:
new RetryTemplateBuilder()
.retryOn(IOException.class)
.traversingCauses()
.build();
This is handy for scenarios where I don't really care about the top-level exception being thrown, but I want to retry if an underlying cause is an IOException, for example.
The new support in Framework doesn't really have an equivalent here.
While I can supply my own exception predicate to the RetryPolicy and check the root cause myself, I wouldn't be able to use the convenient includes() and excludes() configurations for that.
Proposal
Please consider adding that feature, allowing me to do something like this:
new RetryTemplate(RetryPolicy.builder()
.includes(Foo.class)
.excludes(Bar.class)
.traversingCauses()
.build());
The annotation-based equivalent would be:
@Retryable(includes = Foo.class, excludes = Bar.class, traversingCauses = true)
Related Issues
-
35592
Comment From: kzander91
Thanks, @sbrannen, works like a charm 👍
Comment From: sbrannen
Hi @kzander91,
Glad to hear that it works like a charm for you, and thanks for taking it for a spin without us even having to ask you! 👍
FYI: For anyone else reading this, we chose to always check exception causes. In other words, we did not introduce a traversingCauses() method in RetryPolicy.Builder or a traversingCauses attribute in @Retryable.