From 647af4c58d4a8a25c58095086386682c767eb90e Mon Sep 17 00:00:00 2001 From: HARPER Jon Date: Mon, 4 Jul 2022 16:54:39 +0200 Subject: [PATCH] This should fix the same race condition in duplicate as 6c2a62469e53d in create The hashset is copied in toDto other we get "Found shared references to a collection org.hibernate.HibernateException" during the clone Signed-off-by: HARPER Jon --- src/main/java/org/gridsuite/study/server/StudyService.java | 5 ++--- .../NetworkModificationNodeInfoRepositoryProxy.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/StudyService.java b/src/main/java/org/gridsuite/study/server/StudyService.java index d8c12795d..d0613160a 100644 --- a/src/main/java/org/gridsuite/study/server/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/StudyService.java @@ -580,8 +580,7 @@ private CreatedStudyBasicInfos insertStudy(UUID studyUuid, String userId, Networ return createdStudyBasicInfos; } - @Transactional - public CreatedStudyBasicInfos insertDuplicatedStudy(BasicStudyInfos studyInfos, StudyEntity sourceStudy, LoadFlowParametersEntity newLoadFlowParameters, String userId, UUID clonedNetworkUuid) { + private CreatedStudyBasicInfos insertDuplicatedStudy(BasicStudyInfos studyInfos, StudyEntity sourceStudy, LoadFlowParametersEntity newLoadFlowParameters, String userId, UUID clonedNetworkUuid) { Objects.requireNonNull(studyInfos.getId()); Objects.requireNonNull(userId); Objects.requireNonNull(clonedNetworkUuid); @@ -592,7 +591,7 @@ public CreatedStudyBasicInfos insertDuplicatedStudy(BasicStudyInfos studyInfos, UUID reportUuid = UUID.randomUUID(); StudyEntity studyEntity = new StudyEntity(studyInfos.getId(), userId, LocalDateTime.now(ZoneOffset.UTC), clonedNetworkUuid, sourceStudy.getNetworkId(), sourceStudy.getCaseFormat(), sourceStudy.getCaseUuid(), sourceStudy.isCasePrivate(), sourceStudy.getLoadFlowProvider(), newLoadFlowParameters); - CreatedStudyBasicInfos createdStudyBasicInfos = StudyService.toCreatedStudyBasicInfos(insertDuplicatedStudy(studyEntity, sourceStudy.getId(), reportUuid)); + CreatedStudyBasicInfos createdStudyBasicInfos = StudyService.toCreatedStudyBasicInfos(self.insertDuplicatedStudy(studyEntity, sourceStudy.getId(), reportUuid)); studyInfosService.add(createdStudyBasicInfos); emitStudiesChanged(studyInfos.getId(), userId); diff --git a/src/main/java/org/gridsuite/study/server/networkmodificationtree/NetworkModificationNodeInfoRepositoryProxy.java b/src/main/java/org/gridsuite/study/server/networkmodificationtree/NetworkModificationNodeInfoRepositoryProxy.java index 41d65e782..793e0515a 100644 --- a/src/main/java/org/gridsuite/study/server/networkmodificationtree/NetworkModificationNodeInfoRepositoryProxy.java +++ b/src/main/java/org/gridsuite/study/server/networkmodificationtree/NetworkModificationNodeInfoRepositoryProxy.java @@ -68,7 +68,7 @@ public NetworkModificationNode toDto(NetworkModificationNodeInfoEntity node) { int ignoreSize = node.getModificationsToExclude().size(); // to load the lazy collection return completeNodeInfo(node, new NetworkModificationNode(node.getNetworkModificationId(), node.getVariantId(), - node.getModificationsToExclude(), + new HashSet<>(node.getModificationsToExclude()), node.getLoadFlowStatus(), StudyService.fromEntity(node.getLoadFlowResult()), node.getSecurityAnalysisResultUuid(),