diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java index 44d37389710..15b52095e49 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java @@ -62,7 +62,7 @@ class CachePutInterceptor extends AbstractKeyCacheInterceptor exceptionFilter.match(throwable.getClass()) && + return (method, throwable) -> exceptionFilter.match(throwable) && this.predicate.shouldRetry(method, throwable); } diff --git a/spring-core/src/main/java/org/springframework/core/retry/DefaultRetryPolicy.java b/spring-core/src/main/java/org/springframework/core/retry/DefaultRetryPolicy.java index 34a3e30c648..c9f073a96e0 100644 --- a/spring-core/src/main/java/org/springframework/core/retry/DefaultRetryPolicy.java +++ b/spring-core/src/main/java/org/springframework/core/retry/DefaultRetryPolicy.java @@ -59,7 +59,7 @@ class DefaultRetryPolicy implements RetryPolicy { @Override public boolean shouldRetry(Throwable throwable) { - return this.exceptionFilter.match(throwable.getClass()) && + return this.exceptionFilter.match(throwable) && (this.predicate == null || this.predicate.test(throwable)); } diff --git a/spring-core/src/main/java/org/springframework/util/ExceptionTypeFilter.java b/spring-core/src/main/java/org/springframework/util/ExceptionTypeFilter.java index 3bb0c4295ff..715084475aa 100644 --- a/spring-core/src/main/java/org/springframework/util/ExceptionTypeFilter.java +++ b/spring-core/src/main/java/org/springframework/util/ExceptionTypeFilter.java @@ -64,6 +64,16 @@ public class ExceptionTypeFilter extends InstanceFilter candidate) { - assertThat(filter.match(candidate)) - .as("filter '" + filter + "' should match " + candidate.getSimpleName()) + private void assertMatches(Throwable candidate) { + assertThat(this.filter.match(candidate)) + .as("filter '" + this.filter + "' should match " + candidate.getClass().getSimpleName()) .isTrue(); } - private static void assertDoesNotMatch(ExceptionTypeFilter filter, Class candidate) { - assertThat(filter.match(candidate)) - .as("filter '" + filter + "' should not match " + candidate.getSimpleName()) + private void assertDoesNotMatch(Throwable candidate) { + assertThat(this.filter.match(candidate)) + .as("filter '" + this.filter + "' should not match " + candidate.getClass().getSimpleName()) .isFalse(); }