[468178] ConcurrentModificationException while editing a java file with EAR deployed on a server
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java
index ded5647..a563e44 100644
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java
+++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/internal/modulecore/SingleRootExportParticipant.java
@@ -14,6 +14,7 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -95,7 +96,7 @@
try {
resources.clear(); // We want complete control
childModules.clear();
- children = childModules;
+ children = Collections.synchronizedList(childModules);
initializeDelegates();
IContainer container = new SingleRootUtil(component, callbackHandler).getSingleRoot();
@@ -196,12 +197,14 @@
if (isChildModule(vc, reference)) {
ChildModuleReference cm = new ChildModuleReference(reference, new Path("")); //$NON-NLS-1$
List<IChildModuleReference> duplicates = new ArrayList();
- for (IChildModuleReference tmp : children) {
- if (tmp.getRelativeURI().equals(cm.getRelativeURI()))
- duplicates.add(tmp);
+ synchronized(children){
+ for (IChildModuleReference tmp : children) {
+ if (tmp.getRelativeURI().equals(cm.getRelativeURI()))
+ duplicates.add(tmp);
+ }
+ children.removeAll(duplicates);
+ children.add(cm);
}
- children.removeAll(duplicates);
- children.add(cm);
} else {
// It's not a child module, but it is a reference that needs to be added in anyway
refAsResource.add(reference);