fix(场景自动化): 查看场景时报空指针异常

This commit is contained in:
shiziyuan9527 2021-03-23 17:03:00 +08:00
parent 0073ed1307
commit 79e11e651a
1 changed files with 7 additions and 3 deletions

View File

@ -114,10 +114,14 @@ public class ApiAutomationService {
Map<String, String> map = d.getEnvironmentMap(); Map<String, String> map = d.getEnvironmentMap();
if (map != null) { if (map != null) {
if (map.isEmpty()) { if (map.isEmpty()) {
try {
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId"); List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
idList.addAll(new HashSet<>(ids)); idList.addAll(new HashSet<>(ids));
} }
} catch (Exception e) {
LogUtil.error("JSONPath.read projectId fail.");
}
} else { } else {
Set<String> set = d.getEnvironmentMap().keySet(); Set<String> set = d.getEnvironmentMap().keySet();
idList = new ArrayList<>(set); idList = new ArrayList<>(set);