Jelajahi Sumber

fix:修复日志记录的hasException字段没有值的问题

wangzaijun 7 bulan lalu
induk
melakukan
0634e88903

+ 4 - 2
service-deploy/src/main/java/com/simuwang/deploy/components/LoggingAspect.java

@@ -36,7 +36,7 @@ public class LoggingAspect {
     }
 
     @Around("@annotation(annotation)")
-    public Object around(ProceedingJoinPoint joinPoint, SystemLog annotation) {
+    public Object around(ProceedingJoinPoint joinPoint, SystemLog annotation) throws Throwable {
         Class<?> clazz = AopUtils.getTargetClass(joinPoint.getTarget());
         SystemLog systemLog = clazz.getAnnotation(SystemLog.class);
         String title = annotation.value();
@@ -49,7 +49,7 @@ public class LoggingAspect {
                 .params(joinPoint.getArgs() == null ? Objects.toString(request.getParameterMap()) : JSONUtil.toJsonStr(joinPoint.getArgs()));
         StopWatch watch = new StopWatch();
         watch.start();
-        Object result = null;
+        Object result;
         try {
             result = joinPoint.proceed();
             if (annotation.saveResult()) {
@@ -57,6 +57,8 @@ public class LoggingAspect {
             }
         } catch (Throwable throwable) {
             builder.exception(ExceptionUtil.stacktraceToString(throwable));
+            builder.hasException(true);
+            throw throwable;
         } finally {
             watch.stop();
             builder.executeTime(watch.getTotalTimeMillis());