From 78c656fd50edec1a381e0111e71ccffab68247b9 Mon Sep 17 00:00:00 2001 From: Stephan Herrmann Date: Sun, 12 Aug 2012 16:47:31 +0200 Subject: Prevent ConcurrentModificationError seen in the logs. --- .../objectteams/otdt/internal/core/OTJavaElement.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'org.eclipse.jdt.core/model') diff --git a/org.eclipse.jdt.core/model/org/eclipse/objectteams/otdt/internal/core/OTJavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/objectteams/otdt/internal/core/OTJavaElement.java index f98ab684c..90553a3f3 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/objectteams/otdt/internal/core/OTJavaElement.java +++ b/org.eclipse.jdt.core/model/org/eclipse/objectteams/otdt/internal/core/OTJavaElement.java @@ -101,19 +101,21 @@ public abstract class OTJavaElement extends Member implements IOTJavaElement public void addChild(IOTJavaElement child) { if (child != null) - { - this.children.add(child); - } + synchronized (this.children) { + this.children.add(child); + } } protected void compactChildren(IOTJavaElement child) { // FIXME(SH): performance etc. int count = 0; - Iterator it = this.children.iterator(); - while (it.hasNext()) { - if (it.next().equals(child)) { - if (++count > 1) - it.remove(); + synchronized (this.children) { + Iterator it = this.children.iterator(); + while (it.hasNext()) { + if (it.next().equals(child)) { + if (++count > 1) + it.remove(); + } } } } -- cgit v1.2.3