diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java index fc6523f0..d39af82c 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java @@ -58,6 +58,7 @@ import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager; import com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint; import com.helger.phoss.smp.domain.serviceinfo.ISMPProcess; +import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation; import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager; import com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint; import com.helger.phoss.smp.ui.AbstractSMPWebPage; @@ -119,7 +120,8 @@ public LongRunningJobResult createLongRunningJobResult () // Modify all endpoints final MutableInt aChangedEndpoints = new MutableInt (0); final MutableInt aSaveErrors = new MutableInt (0); - final ICommonsSortedSet aChangedServiceGroup = new CommonsTreeSet <> (); + final ICommonsList aChangedSIs = new CommonsArrayList <> (); + // Run in a read-lock aServiceInfoMgr.forEachSMPServiceInformation (aSI -> { if (m_aServiceGroup != null && !aSI.getServiceGroup ().equals (m_aServiceGroup)) { @@ -138,12 +140,20 @@ public LongRunningJobResult createLongRunningJobResult () } if (bChanged) { - if (aServiceInfoMgr.mergeSMPServiceInformation (aSI).isFailure ()) - aSaveErrors.inc (); - aChangedServiceGroup.add (aSI.getServiceGroupID ()); + // Remember and do not merge here to avoid deadlock + aChangedSIs.add (aSI); } }); + // Write out of read-lock + final ICommonsSortedSet aChangedServiceGroup = new CommonsTreeSet <> (); + for (final var aSI : aChangedSIs) + { + if (aServiceInfoMgr.mergeSMPServiceInformation (aSI).isFailure ()) + aSaveErrors.inc (); + aChangedServiceGroup.add (aSI.getServiceGroupID ()); + } + final IHCNode aRes; if (aChangedEndpoints.isGT0 ()) {