mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复aop的afterException无法生效问题
This commit is contained in:
@@ -43,10 +43,14 @@ public class CglibInterceptor implements MethodInterceptor, Serializable {
|
||||
try {
|
||||
// result = proxy.invokeSuper(obj, args);
|
||||
result = proxy.invoke(target, args);
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (final Throwable e) {
|
||||
Throwable throwable = e;
|
||||
if(throwable instanceof InvocationTargetException){
|
||||
throwable = ((InvocationTargetException) throwable).getTargetException();
|
||||
}
|
||||
// 异常回调(只捕获业务代码导致的异常,而非反射导致的异常)
|
||||
if (aspect.afterException(target, method, args, e.getTargetException())) {
|
||||
throw e;
|
||||
if (aspect.afterException(target, method, args, throwable)) {
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,9 +48,14 @@ public class SpringCglibInterceptor implements MethodInterceptor, Serializable {
|
||||
try {
|
||||
// result = proxy.invokeSuper(obj, args);
|
||||
result = proxy.invoke(target, args);
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (Throwable e) {
|
||||
Throwable throwable = e;
|
||||
if(throwable instanceof InvocationTargetException){
|
||||
throwable = ((InvocationTargetException) throwable).getTargetException();
|
||||
}
|
||||
|
||||
// 异常回调(只捕获业务代码导致的异常,而非反射导致的异常)
|
||||
if (aspect.afterException(target, method, args, e.getTargetException())) {
|
||||
if (aspect.afterException(target, method, args, throwable)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user