Parcourir la source

医健宝处理580同步异常问题

yjwang il y a 2 jours
Parent
commit
b199362dca

+ 11 - 5
fs-framework/src/main/java/com/fs/framework/aspectj/LogAspect.java

@@ -135,12 +135,18 @@ public class LogAspect
                 //插入operId
                 String operId = MDC.get("operIds");
                 BeanUtils.copyProperties(operLog, operLogScrm);
-                Long[] operIds = new Long[operId.split(",").length];
-                String[] operIdStrs = operId.split(",");
-                for (int i = 0; i < operIdStrs.length; i++) {
-                    operIds[i] = Long.parseLong(operIdStrs[i]);
+                // MDC 中 operIds 可能为空(如非标准增删改流程接口),需做 null 判断避免 NPE
+                if (operId != null && operId.trim().length() > 0) {
+                    String[] operIdStrs = operId.split(",");
+                    Long[] operIds = new Long[operIdStrs.length];
+                    for (int i = 0; i < operIdStrs.length; i++) {
+                        String s = operIdStrs[i].trim();
+                        if (s.length() > 0) {
+                            operIds[i] = Long.parseLong(s);
+                        }
+                    }
+                    operLogScrm.setOperIds(operIds);
                 }
-                operLogScrm.setOperIds(operIds);
                 resolveParam((ProceedingJoinPoint)joinPoint,operLogScrm);
                 AsyncManager.me().execute(AsyncFactory.recordOperScrm(operLogScrm));
             }