JAL-2235 raise exceptions if self reference or reference to non-ds sequence is passed...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 28 Sep 2016 14:25:29 +0000 (15:25 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 28 Sep 2016 14:25:29 +0000 (15:25 +0100)
src/jalview/datamodel/Sequence.java

index d295480..29d114d 100755 (executable)
@@ -1011,7 +1011,16 @@ public class Sequence extends ASequence implements SequenceI
   @Override
   public void setDatasetSequence(SequenceI seq)
   {
-    // TODO check for circular reference before setting?
+    if (seq == this)
+    {
+      throw new Error(
+              "Implementation Error: self reference passed to SequenceI.setDatasetSequence");
+    }
+    if (seq != null && seq.getDatasetSequence() != null)
+    {
+      throw new Error(
+              "Implementation error: cascading dataset sequences are not allowed.");
+    }
     datasetSequence = seq;
   }