From b6acaa87c22c1d31deb3f9b87a143def43ae34b7 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 13 Apr 2015 16:03:23 +0100 Subject: [PATCH] JAL-1681 work around ConcurrentModificationException on startup --- src/jalview/workers/ComplementConsensusThread.java | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/jalview/workers/ComplementConsensusThread.java b/src/jalview/workers/ComplementConsensusThread.java index 2e4424e..71bfb40 100644 --- a/src/jalview/workers/ComplementConsensusThread.java +++ b/src/jalview/workers/ComplementConsensusThread.java @@ -1,5 +1,6 @@ package jalview.workers; +import java.util.ConcurrentModificationException; import java.util.Hashtable; import jalview.analysis.AAFrequency; @@ -37,13 +38,31 @@ public class ComplementConsensusThread extends ConsensusThread return alignViewport.getComplementConsensusHash(); } + /** + * Calculate the cDNA consensus and store it on the Viewport + */ @Override protected void computeConsensus(AlignmentI alignment) { Hashtable[] hconsensus = new Hashtable[alignment.getWidth()]; SequenceI[] aseqs = getSequences(); - AAFrequency.calculateCdna(alignment, hconsensus); + + /* + * Allow 3 tries at this, since this thread can start up while we are still + * modifying protein-codon mappings on the alignment + */ + for (int i = 0; i < 3; i++) + { + try + { + AAFrequency.calculateCdna(alignment, hconsensus); + break; + } catch (ConcurrentModificationException e) + { + // try again + } + } alignViewport.setComplementConsensusHash(hconsensus); } -- 1.7.10.2