mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Support direct matching against exceptions in ExceptionTypeFilter
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
This commit is contained in:
+1
-1
@@ -62,7 +62,7 @@ class CachePutInterceptor extends AbstractKeyCacheInterceptor<CachePutOperation,
|
||||
}
|
||||
catch (CacheOperationInvoker.ThrowableWrapper ex) {
|
||||
Throwable original = ex.getOriginal();
|
||||
if (!earlyPut && operation.getExceptionTypeFilter().match(original.getClass())) {
|
||||
if (!earlyPut && operation.getExceptionTypeFilter().match(original)) {
|
||||
cacheValue(context, value);
|
||||
}
|
||||
throw ex;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
|
||||
}
|
||||
catch (CacheOperationInvoker.ThrowableWrapper ex) {
|
||||
Throwable original = ex.getOriginal();
|
||||
if (!earlyRemove && operation.getExceptionTypeFilter().match(original.getClass())) {
|
||||
if (!earlyRemove && operation.getExceptionTypeFilter().match(original)) {
|
||||
removeAll(context);
|
||||
}
|
||||
throw ex;
|
||||
|
||||
+4
-4
@@ -56,12 +56,12 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (CacheOperationInvoker.ThrowableWrapper wrapperException) {
|
||||
Throwable ex = wrapperException.getOriginal();
|
||||
if (!earlyRemove && operation.getExceptionTypeFilter().match(ex.getClass())) {
|
||||
catch (CacheOperationInvoker.ThrowableWrapper ex) {
|
||||
Throwable original = ex.getOriginal();
|
||||
if (!earlyRemove && operation.getExceptionTypeFilter().match(original)) {
|
||||
removeValue(context);
|
||||
}
|
||||
throw wrapperException;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class CacheResultInterceptor extends AbstractKeyCacheInterceptor<CacheResultOper
|
||||
if (exceptionCache == null) {
|
||||
return;
|
||||
}
|
||||
if (filter.match(ex.getClass())) {
|
||||
if (filter.match(ex)) {
|
||||
doPut(exceptionCache, cacheKey, ex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user