NPE race condition alert - see JAL-661
[jalview.git] / src / jalview / analysis / AAFrequency.java
index 11e7a3d..31cb7ad 100755 (executable)
@@ -105,6 +105,11 @@ public class AAFrequency
 
       for (j = 0; j < jSize; j++)
       {
+        if (sequences[j]==null)
+        {
+          System.err.println("WARNING: Consensus skipping null sequence - possible race condition.");
+          continue;
+        }
         seq = sequences[j].getSequence();
         if (seq.length > i)
         {
@@ -204,16 +209,20 @@ public class AAFrequency
           boolean includeAllConsSymbols, char[] alphabet)
   {
     float tval, value;
-    if (consensus==null || consensus.annotations==null || consensus.annotations.length<width)
+    if (consensus == null || consensus.annotations == null
+            || consensus.annotations.length < width)
     {
-      // called with a bad alignment annotation row - wait for it to be initialised properly
+      // called with a bad alignment annotation row - wait for it to be
+      // initialised properly
       return;
     }
     for (int i = iStart; i < width; i++)
     {
-      if (i>=hconsensus.length) {
-        // happens if sequences calculated over were shorter than alignment width
-        consensus.annotations[i]=null;
+      if (i >= hconsensus.length)
+      {
+        // happens if sequences calculated over were shorter than alignment
+        // width
+        consensus.annotations[i] = null;
         continue;
       }
       value = 0;