mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
fixed a ConcurrentModificationException
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15703 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
b70935c197
commit
ef15a02e70
1 file changed
+13
-5
@@ -26,6 +26,7 @@ package hudson;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.util.DescriptorList;
|
||||
import hudson.util.Memoizer;
|
||||
import hudson.util.Iterators;
|
||||
import hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson;
|
||||
|
||||
import java.util.AbstractList;
|
||||
@@ -102,7 +103,8 @@ public class ExtensionList<T> extends AbstractList<T> {
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return ensureLoaded().iterator();
|
||||
// we need to intercept mutation, so for now don't allow Iterator.remove
|
||||
return Iterators.readOnly(ensureLoaded().iterator());
|
||||
}
|
||||
|
||||
public T get(int index) {
|
||||
@@ -114,14 +116,20 @@ public class ExtensionList<T> extends AbstractList<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized T remove(int index) {
|
||||
T t = get(index);
|
||||
legacyInstances.remove(t);
|
||||
public synchronized boolean remove(Object o) {
|
||||
legacyInstances.remove(o);
|
||||
if(extensions!=null) {
|
||||
List<T> r = new ArrayList<T>(extensions);
|
||||
r.remove(t);
|
||||
r.remove(o);
|
||||
extensions = sort(r);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized T remove(int index) {
|
||||
T t = get(index);
|
||||
remove(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user