Browse Source

REPORT-73331【设计器环境监测】远程环境缺少jar,没有检测到异常

修复远程时,缺少 JAR 的逻辑
feature/x
Harrison 2 years ago
parent
commit
6bcad8f5f7
  1. 47
      designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java

47
designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java vendored

@ -12,6 +12,7 @@ import com.fr.env.detect.bean.ExceptionSolution;
import com.fr.env.detect.bean.ExceptionTips;
import com.fr.env.detect.bean.Message;
import com.fr.general.build.BuildInfo;
import com.fr.general.build.BuildInfoManager;
import com.fr.general.build.BuildInfoOperator;
import com.fr.general.build.impl.BuildInfoOperatorImpl;
import com.fr.third.guava.collect.Lists;
@ -22,6 +23,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
@ -42,17 +45,38 @@ public class JarLackDetector extends AbstractExceptionDetector {
@Override
public DetectorResult detect() {
// 不支持远程
List<BuildInfo> lackInfos;
// 远程
if (!WorkContext.getCurrent().isLocal()) {
return DetectorResult.normal(type());
// 检测有哪些 JAR 包, 当前是否缺少对应的 JAR 包
BuildInfoOperator buildInfoOperator = WorkContext.getCurrent().get(BuildInfoOperator.class);
// 远程情况
List<BuildInfo> remoteInfos = buildInfoOperator.getBuildInfos();
// 本地情况
List<BuildInfo> localInfos = BuildInfoManager.getInstance().getInfos();
Set<String> remoteSet = remoteInfos.stream()
.filter(this::isExistInfo)
.map(BuildInfo::getJar)
.collect(Collectors.toSet());
Predicate<BuildInfo> remoteNotContains = (e) -> !remoteSet.contains(e.getJar());
lackInfos = localInfos.stream()
.filter(this::isExistInfo)
.filter(remoteNotContains)
.collect(Collectors.toList());
} else {
// 本地
// 检测有哪些 JAR 包, 当前是否缺少对应的 JAR 包
BuildInfoOperator buildInfoOperator = new BuildInfoOperatorImpl();
List<BuildInfo> buildInfos = buildInfoOperator.getBuildInfos();
lackInfos = buildInfos.stream()
.filter(this::isLackInfo)
.collect(Collectors.toList());
}
// 检测有哪些 JAR 包, 当前是否缺少对应的 JAR 包
BuildInfoOperator buildInfoOperator = new BuildInfoOperatorImpl();
List<BuildInfo> buildInfos = buildInfoOperator.getBuildInfos();
List<BuildInfo> lackInfos = buildInfos.stream()
.filter(this::isLackInfo)
.collect(Collectors.toList());
if (Collections.isEmpty(lackInfos)) {
return DetectorResult.normal(type());
@ -77,6 +101,11 @@ public class JarLackDetector extends AbstractExceptionDetector {
return ExceptionLog.create(Toolkit.i18nText(type().getLogLocale()) + message);
}
private boolean isExistInfo(BuildInfo e) {
return !isLackInfo(e);
}
private boolean isLackInfo(BuildInfo e) {
return StringUtils.isEmpty(e.getGroupBuild());

Loading…
Cancel
Save