diff --git a/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java b/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java index 9a1bb097db..b566aa55f3 100644 --- a/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java +++ b/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java @@ -43,11 +43,12 @@ public class RelationshipEdgeService { example.createCriteria() .andSourceIdEqualTo(sourceId) .andTargetIdEqualTo(targetId); - - String graphId = relationshipEdgeMapper.selectByExample(example).get(0).getGraphId(); - updateGraphId(graphId, sourceId, targetId); - - relationshipEdgeMapper.deleteByExample(example); + List list = relationshipEdgeMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(list)) { + String graphId = relationshipEdgeMapper.selectByExample(example).get(0).getGraphId(); + updateGraphId(graphId, sourceId, targetId); + relationshipEdgeMapper.deleteByExample(example); + } } public void delete(String sourceId ,List targetIds) {