From bfe2ce7ec6dc0598f06b91d0e380e6fe36e30e47 Mon Sep 17 00:00:00 2001 From: James Procter Date: Wed, 25 Oct 2023 11:17:06 +0100 Subject: [PATCH] JAL-4312 defend against ConcurrentModificationException --- src/jalview/workers/AlignCalcManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; -- 1.7.10.2