JAL-4312 defend against ConcurrentModificationException bug/JAL-4313_cme_in_tests
authorJames Procter <j.procter@dundee.ac.uk>
Wed, 25 Oct 2023 10:17:06 +0000 (11:17 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Wed, 25 Oct 2023 10:17:06 +0000 (11:17 +0100)
src/jalview/workers/AlignCalcManager.java

index 435d40c..508a069 100644 (file)
@@ -305,14 +305,16 @@ public class AlignCalcManager implements AlignCalcManagerI
           Class<? extends AlignCalcWorkerI> workerClass)
   {
     List<AlignCalcWorkerI> workingClass = new ArrayList<AlignCalcWorkerI>();
+    AlignCalcWorkerI[] workers;
     synchronized (canUpdate)
     {
-      for (AlignCalcWorkerI worker : canUpdate)
+      workers = canUpdate.toArray(new AlignCalcWorkerI[0]);
+    }
+    for (AlignCalcWorkerI worker : workers)
+    {
+      if (workerClass.equals(worker.getClass()))
       {
-        if (workerClass.equals(worker.getClass()))
-        {
-          workingClass.add(worker);
-        }
+        workingClass.add(worker);
       }
     }
     return (workingClass.size() == 0) ? null : workingClass;