From: gmungoc Date: Mon, 13 Apr 2015 15:03:23 +0000 (+0100) Subject: JAL-1681 work around ConcurrentModificationException on startup X-Git-Tag: Jalview_2_9~69^2~3 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=b6acaa87c22c1d31deb3f9b87a143def43ae34b7 JAL-1681 work around ConcurrentModificationException on startup --- 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); }