Skip to content

Use ExceptionTypeFilter to filter includes and excludes for retry policies #35109

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

Closed
wants to merge 1 commit into from

Conversation

remeio
Copy link
Contributor

@remeio remeio commented Jun 25, 2025

It's easy to filter Throwable with ExceptionTypeFilter. Otherwise, we would have to handle inclusions and exclusions everywhere.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 25, 2025
@sbrannen sbrannen self-assigned this Jun 25, 2025
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Jun 25, 2025
@remeio remeio closed this Jun 29, 2025
@remeio remeio reopened this Jun 29, 2025
@sbrannen sbrannen added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 3, 2025
@sbrannen sbrannen added this to the 7.0.0-M7 milestone Jul 3, 2025
@sbrannen sbrannen changed the title Filter throwable by ExceptionTypeFilter Use ExceptionTypeFilter to filter includes and excludes for retry policies Jul 3, 2025
@sbrannen sbrannen closed this in 489ebd2 Jul 3, 2025
sbrannen added a commit that referenced this pull request Jul 3, 2025
sbrannen added a commit that referenced this pull request Jul 5, 2025
Prior to this commit, ExceptionTypeFilter only supported matching
against an exception type. However, most use cases involve matching
against an exception instance. Moreover, every use case within the core
Spring Framework uses ExceptionTypeFilter to match against concrete
exception instances.

This commit therefore introduces an overloaded match(Throwable) method
in ExceptionTypeFilter in order to provide support for the most common
use cases.

See gh-35109
Closes gh-35160
sbrannen added a commit that referenced this pull request Jul 5, 2025
In commit 97522cf, I implemented a
short-circuiting matching algorithm in DefaultRetryPolicy for includes
and excludes, which was later copied to MethodRetrySpec.

After we switched to using ExceptionTypeFilter, I realized that the
matching algorithm in InstanceFilter (the superclass of
ExceptionTypeFilter) does not exhibit the same short-circuiting
characteristics.

In light of that, this commit revises the matching algorithm in
InstanceFilter to mirror the original short-circuiting algorithm in
DefaultRetryPolicy.

See gh-35058
See gh-35109
See gh-35160
Closes gh-35161
@sbrannen
Copy link
Member

sbrannen commented Jul 5, 2025

This has been merged into main in 489ebd2 and revised in 58061ae.

In addition, this PR inspired the following work.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants