From 3d15945cbf4a0f70bde108bcceb42bb9553c1967 Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 8 Jun 2023 11:54:51 +0100 Subject: [PATCH] JAL-4196 make very sure we avoid CME by defensively copying the Map.values() to another list and synchronising on it --- src/jalview/workers/AlignCalcManager.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java index d81db8c..fc28e53 100644 --- a/src/jalview/workers/AlignCalcManager.java +++ b/src/jalview/workers/AlignCalcManager.java @@ -25,6 +25,7 @@ import jalview.api.AlignCalcWorkerI; import jalview.datamodel.AlignmentAnnotation; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Hashtable; @@ -208,9 +209,18 @@ public class AlignCalcManager implements AlignCalcManagerI } synchronized (updating) { - for (List workers : updating.values()) + Collection> workersLists = updating.values(); + synchronized (workersLists) { - working |= workers.size() > 0; + for (List workers : workersLists) + { + if (workers!=null) + { + synchronized (workers) { + working |= workers.size() > 0; + } + } + } } } return working; -- 1.7.10.2