From 3187e7b12127c71cc514b52d48c72144f3976db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E5=86=B0?= <741531906@qq.com> Date: Fri, 15 Dec 2023 09:50:53 +0000 Subject: [PATCH] =?UTF-8?q?[server]=20=E8=A7=A3=E5=86=B3=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=B5=81=E7=A8=8B,=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8Fenv?= =?UTF-8?q?=E9=87=8C=E5=87=BA=E7=8E=B0value=3D=3Dnull=E5=87=BA=E7=8E=B0nul?= =?UTF-8?q?l=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周冰 <741531906@qq.com> --- .../src/main/java/org/dromara/jpom/util/CommandUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/common/src/main/java/org/dromara/jpom/util/CommandUtil.java b/modules/common/src/main/java/org/dromara/jpom/util/CommandUtil.java index 59090a93e..ec51f3fb7 100644 --- a/modules/common/src/main/java/org/dromara/jpom/util/CommandUtil.java +++ b/modules/common/src/main/java/org/dromara/jpom/util/CommandUtil.java @@ -361,7 +361,9 @@ public class CommandUtil { processBuilder.redirectErrorStream(true); processBuilder.command(command); Optional.ofNullable(baseDir).ifPresent(processBuilder::directory); - + // 新增逻辑,将env和environment里value==null替换成空字符,防止putAll出现空指针报错 + env.replaceAll((k,v)-> Optional.ofNullable(v).orElse(StrUtil.EMPTY)); + environment.replaceAll((k,v)-> Optional.ofNullable(v).orElse(StrUtil.EMPTY)); Map environment = processBuilder.environment(); // 环境变量 Optional.ofNullable(env).ifPresent(environment::putAll);