OSDN Git Service

ConcurrentModificationException in AbstractPropertiesFieldsPart
authorTor Norbye <tnorbye@google.com>
Tue, 15 Mar 2011 03:57:35 +0000 (20:57 -0700)
committerTor Norbye <tnorbye@google.com>
Tue, 15 Mar 2011 18:12:27 +0000 (11:12 -0700)
I ran into a ConcurrentModificationException when creating an XML file
using the plain XML wizard (not the Android XML wizard - because I
wanted to create an XML drawable which is not supported by the new
Android XML wizard.)

Change-Id: Id2ae606e9da47e6f7d42cf6a0dea61eb3e9ca15d

eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java

index 06169d2..0d72614 100755 (executable)
@@ -34,6 +34,7 @@ import org.eclipse.ui.forms.widgets.Section;
 
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 
 /**
  * Section part for editing fields of a properties file in an Export editor.
@@ -302,13 +303,15 @@ abstract class AbstractPropertiesFieldsPart extends ManifestSectionPart {
         }
 
         // Clear the text of any keyword we didn't find in the document
-        for (String key : allKeywords) {
+        Iterator<String> iterator = allKeywords.iterator();
+        while (iterator.hasNext()) {
+            String key = iterator.next();
             Control field = mNameToField.get(key);
             if (field != null) {
                 try {
                     mInternalTextUpdate = true;
                     setFieldText(field, "");
-                    allKeywords.remove(key);
+                    iterator.remove();
                 } finally {
                     mInternalTextUpdate = false;
                 }