From: James Procter Date: Thu, 8 Jun 2023 10:54:51 +0000 (+0100) Subject: JAL-4196 make very sure we avoid CME by defensively copying the Map.values() to anoth... X-Git-Tag: Release_2_11_4_0~262^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3d15945cbf4a0f70bde108bcceb42bb9553c1967;p=jalview.git JAL-4196 make very sure we avoid CME by defensively copying the Map.values() to another list and synchronising on it --- 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;