polishing
This commit fixes the handling of cached exceptions in the JSR-107 advisor. Such exceptions are now properly propagated instead of being wrapped in a RuntimeException. Issue: SPR-9616
This commit is contained in:
@@ -67,10 +67,8 @@ public aspect JCacheCacheAspect extends JCacheAspectSupport {
|
||||
return execute(aspectJInvoker, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs());
|
||||
}
|
||||
catch (CacheOperationInvoker.ThrowableWrapper th) {
|
||||
if (th.getOriginal() instanceof RuntimeException) {
|
||||
throw (RuntimeException) th.getOriginal();
|
||||
}
|
||||
throw th; // Lose original checked exception
|
||||
AnyThrow.throwUnchecked(th.getOriginal());
|
||||
return null; // never reached
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,4 +107,17 @@ public aspect JCacheCacheAspect extends JCacheAspectSupport {
|
||||
private pointcut executionOfCacheRemoveAllMethod() :
|
||||
execution(@CacheRemoveAll * *(..));
|
||||
|
||||
|
||||
private static class AnyThrow {
|
||||
|
||||
private static void throwUnchecked(Throwable e) {
|
||||
AnyThrow.<RuntimeException>throwAny(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <E extends Throwable> void throwAny(Throwable e) throws E {
|
||||
throw (E)e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user