Skip to content

Match against exception causes in @Retryable and RetryPolicy #35583

@kzander91

Description

@kzander91

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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions