From: Jim Procter Date: Thu, 14 Jul 2016 10:43:53 +0000 (+0100) Subject: JAL-1115 change implementation to avoid possibility of deadlock X-Git-Tag: Release_2_10_0~140^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a24dd1c4927582a629b2ce43c3786abe1c247847;p=jalview.git JAL-1115 change implementation to avoid possibility of deadlock --- diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 0ee0344..d737bd5 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1373,10 +1373,6 @@ public class Alignment implements AlignmentI @Override public void append(AlignmentI toappend) { - if (toappend == this) - { - System.err.println("Self append may cause a deadlock."); - } // TODO JAL-1270 needs test coverage // currently tested for use in jalview.gui.SequenceFetcher boolean samegap = toappend.getGapCharacter() == getGapCharacter(); @@ -1388,6 +1384,8 @@ public class Alignment implements AlignmentI .getFullAlignment().getSequences() : toappend.getSequences(); if (sqs != null) { + // avoid self append deadlock by + List toappendsq = new ArrayList(); synchronized (sqs) { for (SequenceI addedsq : sqs) @@ -1403,9 +1401,13 @@ public class Alignment implements AlignmentI } } } - addSequence(addedsq); + toappendsq.add(addedsq); } } + for (SequenceI addedsq : toappendsq) + { + addSequence(addedsq); + } } AlignmentAnnotation[] alan = toappend.getAlignmentAnnotation(); for (int a = 0; alan != null && a < alan.length; a++)