diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index 07ad33383a..e6eee7d951 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -1365,12 +1365,14 @@ public class ApiModuleService extends NodeTreeService { int finalI = i; //在选择的模块下建模块,查看选择的模块下有没有同名的模块 List moduleList = pidChildrenMap.get(parentModule.getId()); - List collect1 = moduleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList()); - if (collect1.isEmpty()) { - return createModule(tagTree, i, parentModule, moduleMap, pidChildrenMap, idPathMap); - } else { - returnModule = collect1.get(0); - parentModule = collect1.get(0); + if (moduleList != null && !moduleList.isEmpty()) { + List collect1 = moduleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList()); + if (collect1.isEmpty()) { + return createModule(tagTree, i, parentModule, moduleMap, pidChildrenMap, idPathMap); + } else { + returnModule = collect1.get(0); + parentModule = collect1.get(0); + } } } return returnModule;