Match if empty by default in InstanceFilter and ExceptionTypeFilter

Prior to this commit, the constructors for InstanceFilter and
ExceptionTypeFilter required one to supply the matchIfEmpty flag.
However, users will typically want that to be true. Moreover, we always
supply true for the matchIfEmpty flag within the Spring Framework.

This commit therefore makes the matchIfEmpty flag optional by
introducing overloaded constructors for InstanceFilter and
ExceptionTypeFilter that only accept the includes and excludes
collections.

In addition, this commit overhauls the Javadoc for InstanceFilter and
ExceptionTypeFilter, fixing several issues in the documentation.

Furthermore, this commit applies consistent @⁠Nullable declarations
in ExceptionTypeFilter.

Closes gh-35158
This commit is contained in:
Sam Brannen
2025-07-04 18:11:12 +02:00
parent 46c40e7b96
commit d510b738f4
7 changed files with 97 additions and 39 deletions
@@ -64,7 +64,7 @@ public record MethodRetrySpec(
MethodRetryPredicate combinedPredicate() {
ExceptionTypeFilter exceptionFilter = new ExceptionTypeFilter(this.includes, this.excludes, true);
ExceptionTypeFilter exceptionFilter = new ExceptionTypeFilter(this.includes, this.excludes);
return (method, throwable) -> exceptionFilter.match(throwable.getClass()) &&
this.predicate.shouldRetry(method, throwable);
}