Skip to content
Permalink
Browse files

[FIXED JENKINS-18329] - Prevent ConcurrentModificationException

Replace Iterator with ListIterator and use iterator methods for adding
and removing. This should fix any ConcurrentModificationExceptions
  • Loading branch information
svogt committed Jul 2, 2013
1 parent b1f5341 commit c59089bf24ae828a1367f85732392f2f4a5cb2a5
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/main/java/hudson/scm/AbstractCvs.java
@@ -35,6 +35,7 @@
import hudson.remoting.VirtualChannel;
import hudson.scm.cvstagging.CvsTagAction;
import hudson.util.Secret;

import org.apache.commons.io.output.DeferredFileOutputStream;
import org.netbeans.lib.cvsclient.CVSRoot;
import org.netbeans.lib.cvsclient.Client;
@@ -70,6 +71,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
@@ -507,15 +509,15 @@ protected PollingResult compareRemoteRevisionWith(final AbstractProject<?, ?> pr
// update the remote state with the changes we've just retrieved
for (CvsFile changedFile : changes) {
boolean changed = false;
for (Iterator<CvsFile> itr = remoteFiles.iterator(); itr.hasNext();) {
for (ListIterator<CvsFile> itr = remoteFiles.listIterator(); itr.hasNext();) {
CvsFile existingFile = itr.next();
if (!changedFile.getName().equals(existingFile.getName())) {
continue;
}

remoteFiles.remove(existingFile);
itr.remove();
if (!changedFile.isDead()) {
remoteFiles.add(changedFile);
itr.add(changedFile);
}
changed = true;
}

0 comments on commit c59089b

Please sign in to comment.
You can’t perform that action at this time.