Forráskód Böngészése

Bootstrap 中添加对 NullPointerException 异常的处理

reghao 1 éve
szülő
commit
b296d1846e

+ 1 - 0
mgr/src/main/java/cn/reghao/devops/mgr/mgr/app/service/bd/impl/BuildAppImpl.java

@@ -88,6 +88,7 @@ public class BuildAppImpl implements BuildApp {
         appBuildService.updateBeforeBuild(appId, buildBy);
         CompletableFuture<HandlerResult> future = CompletableFuture.supplyAsync(buildChain, buildPool)
                 .whenComplete((chainResult, throwable) -> {
+                    log.info("{} 异步构建后处理", appId);
                     BuildChainResult buildChainResult = (BuildChainResult) chainResult;
                     Result result = buildChainResult.getResult();
                     AppBuilding appBuilding = appBuildService.updateAfterBuild(buildChainResult);

+ 8 - 2
mgr/src/main/java/cn/reghao/devops/mgr/mgr/build/chain/Bootstrap.java

@@ -1,6 +1,7 @@
 package cn.reghao.devops.mgr.mgr.build.chain;
 
 import cn.reghao.devops.mgr.mgr.build.chain.impl.BuildChainResult;
+import cn.reghao.jutil.jdk.exception.ExceptionUtil;
 import cn.reghao.jutil.jdk.result.Result;
 import cn.reghao.jutil.jdk.result.ResultStatus;
 
@@ -29,8 +30,13 @@ public class Bootstrap<K extends HandlerParam, V extends HandlerResult> implemen
             first.handle(buildParam, buildResult);
             result = Result.result(ResultStatus.SUCCESS);
         } catch (Exception e) {
-            //String errMsg = ExceptionUtil.stackTrace(e);
-            String errMsg = e.getMessage();
+            String errMsg;
+            if (e instanceof NullPointerException) {
+                errMsg = ExceptionUtil.stackTrace(e);
+            } else {
+                errMsg = e.getMessage();
+            }
+
             if (errMsg.length() > 20_000) {
                 errMsg = errMsg.substring(0, 20_000);
             }