From 5a15b7773aaad3bba1bb342198e2bcf4cc2cdffe Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 18 Feb 2011 17:12:22 +0000 Subject: [PATCH] fix for occasional race conditions --- src/jalview/analysis/Conservation.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index b557c5a..2ffb4de 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -100,7 +100,7 @@ public class Conservation int s, sSize = sequences.size(); SequenceI[] sarray = new SequenceI[sSize]; this.sequences = sarray; - + try { for (s = 0; s < sSize; s++) { sarray[s] = (SequenceI) sequences.elementAt(s); @@ -109,6 +109,12 @@ public class Conservation maxLength = sarray[s].getLength(); } } + } catch (ArrayIndexOutOfBoundsException ex) + { + // bail - another thread has modified the sequence array, so the current calculation is probably invalid. + this.sequences=new SequenceI[0]; + maxLength=0; + } } /** @@ -271,7 +277,9 @@ public class Conservation } } - total[i - start] = resultHash; + if (total.length>0) { + total[i - start] = resultHash; + } } } -- 1.7.10.2