Fix concurrent modification in java rewriter
@@ -28,8 +28,10 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.ServiceLoader;
import java.util.TreeSet;
import javax.annotation.Nullable;
@@ -471,11 +473,12 @@ public final class PostprocessingMachine {
}
}
- for (Map.Entry<String, ImportCandidate> candidateEntry : importCandidates.entries()) {
+ for (Iterator<Entry<String, ImportCandidate>> it = importCandidates.entries().iterator(); it.hasNext();) {
+ Map.Entry<String, ImportCandidate> candidateEntry = it.next();
ImportCandidate candidate = candidateEntry.getValue();
String originalFullyName = originalImports.get(candidate.simpleName);
if (originalFullyName != null && !originalFullyName.equals(candidate.preparedImport)) {
- importCandidates.remove(candidateEntry.getKey(), candidateEntry.getValue());
+ it.remove();
}
}
}
