From 9bc33d000e8d8e0ddbaac28033bcf9b91839d855 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 17 Apr 2007 20:21:22 +0000 Subject: [PATCH] spirit fix found in RSE 713 applied to open source --- .../dstore/internal/core/util/XMLparser.java | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java index 607b5699188..21d71b76c2e 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java @@ -530,38 +530,44 @@ public class XMLparser if (parent != null && parent.getNestedSize() > 0 && _dataStore.isVirtual()) { - // end of children of parent - // find all spirits that match non-spirits List toDelete = new ArrayList(); - for (int s= 0; s < parent.getNestedSize(); s++) + List nested = parent.getNestedData(); + synchronized (nested) { - DataElement element = parent.get(s); - if (element.isSpirit()) + for (int s= 0; s < nested.size(); s++) { - String name = element.getName(); - String value = element.getValue(); - - // delete this element if there's another one with the same name and value - for (int n = 0; n < parent.getNestedSize(); n++) + DataElement element = (DataElement)nested.get(s); + if (element.isSpirit()) { - if (n != s) + boolean addedToDelete = false; + String name = element.getName(); + String value = element.getValue(); + + // delete this element if there's another one with the same name and value + for (int n = 0; n < parent.getNestedSize() && !addedToDelete; n++) { - DataElement compare = parent.get(n); - String cname = compare.getName(); - String cvalue = compare.getValue(); - if (!compare.isSpirit() && cname.equals(name) && cvalue.equals(value)) - toDelete.add(compare); + if (n != s) + { + DataElement compare = parent.get(n); + String cname = compare.getName(); + String cvalue = compare.getValue(); + if (!compare.isSpirit() && cname.equals(name) && cvalue.equals(value)) + { + toDelete.add(element); + addedToDelete = true; + } + } } } + } + + // delete elements + for (int d = 0; d < toDelete.size(); d++) + { + DataElement delement = (DataElement)toDelete.get(d); + _dataStore.deleteObject(parent,delement); } } - - // delete elements - for (int d = 0; d < toDelete.size(); d++) - { - DataElement delement = (DataElement)toDelete.get(d); - _dataStore.deleteObject(parent,delement); - } } _tagStack.pop();