Skip to content

Commit

Permalink
[FIXED JENKINS-18329] - Prevent ConcurrentModificationException
Browse files Browse the repository at this point in the history
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 c59089b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/hudson/scm/AbstractCvs.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c59089b

Please sign in to comment.