From: James Procter Date: Wed, 25 Oct 2023 10:17:06 +0000 (+0100) Subject: JAL-4312 defend against ConcurrentModificationException X-Git-Tag: Release_2_11_4_0~124^2^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bfe2ce7ec6dc0598f06b91d0e380e6fe36e30e47;p=jalview.git JAL-4312 defend against ConcurrentModificationException --- diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java index 435d40c..508a069 100644 --- a/src/jalview/workers/AlignCalcManager.java +++ b/src/jalview/workers/AlignCalcManager.java @@ -305,14 +305,16 @@ public class AlignCalcManager implements AlignCalcManagerI Class workerClass) { List workingClass = new ArrayList(); + 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;