From fd065d8808912988faa2ed961bf76a3c5097c49d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 18 Jun 2013 17:06:38 +0100 Subject: [PATCH] JAL-674 - avoid java.util.ConcurrentModificationException on the pdbfile list --- src/jalview/ws/dbsources/Pdb.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index 631a79f..b8ab8ed 100644 --- a/src/jalview/ws/dbsources/Pdb.java +++ b/src/jalview/ws/dbsources/Pdb.java @@ -23,6 +23,8 @@ import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import MCview.PDBChain; @@ -133,6 +135,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy jalview.io.AppletFormatAdapter.FILE, "PDB"); if (pdbfile != null) { + List toremove=new ArrayList(); for (SequenceI pdbcs : pdbfile.getSequences()) { String chid = null; @@ -177,17 +180,23 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy } else { - // remove this sequence from the alignment - since it's not from the - // right chain - pdbfile.deleteSequence(pdbcs); + // mark this sequence to be removed from the alignment + // - since it's not from the right chain + toremove.add(pdbcs); } } + // now remove marked sequences + for (SequenceI pdbcs:toremove) { + pdbfile.deleteSequence(pdbcs); + } } + if (pdbfile == null || pdbfile.getHeight() < 1) { throw new Exception("No PDB Records for " + id + " chain " + ((chain == null) ? "' '" : chain)); } + } catch (Exception ex) // Problem parsing PDB file { stopQuery(); -- 1.7.10.2