diff --git a/backend/src/main/java/io/metersphere/metadata/service/FileAssociationService.java b/backend/src/main/java/io/metersphere/metadata/service/FileAssociationService.java index 94dc0ed64c..9e92662e78 100644 --- a/backend/src/main/java/io/metersphere/metadata/service/FileAssociationService.java +++ b/backend/src/main/java/io/metersphere/metadata/service/FileAssociationService.java @@ -165,12 +165,16 @@ public class FileAssociationService { private List getRefFiles(Body body) { List files = new ArrayList<>(); - body.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { - files.addAll(keyValue.getFiles().stream().filter(BodyFile::isRef).collect(Collectors.toList())); - }); - body.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { - files.addAll(keyValue.getFiles().stream().filter(BodyFile::isRef).collect(Collectors.toList())); - }); + if (body != null && !CollectionUtils.isEmpty(body.getKvs())) { + body.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { + files.addAll(keyValue.getFiles().stream().filter(BodyFile::isRef).collect(Collectors.toList())); + }); + } + if (body != null && !CollectionUtils.isEmpty(body.getBinary())) { + body.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { + files.addAll(keyValue.getFiles().stream().filter(BodyFile::isRef).collect(Collectors.toList())); + }); + } return files; } }