From 6782857ba8efe4be2860bee76f3483976af10125 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 25 Feb 2009 00:05:25 +0000 Subject: [PATCH] Fixed a possible concurrent modification problem. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15698 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/ExtensionList.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/ExtensionList.java b/core/src/main/java/hudson/ExtensionList.java index 1c3dac21ca..0512876f68 100644 --- a/core/src/main/java/hudson/ExtensionList.java +++ b/core/src/main/java/hudson/ExtensionList.java @@ -69,11 +69,12 @@ public class ExtensionList extends AbstractList { /** * Place to store manually registered instances with the per-Hudson scope. + * {@link CopyOnWriteArrayList} is used here to support concurrent iterations and mutation. */ - private final List legacyInstances; + private final CopyOnWriteArrayList legacyInstances; protected ExtensionList(Hudson hudson, Class extensionType) { - this(hudson,extensionType,new Vector()); + this(hudson,extensionType,new CopyOnWriteArrayList()); } /** @@ -83,7 +84,7 @@ public class ExtensionList extends AbstractList { * omits this uses a new {@link Vector}, making the storage lifespan tied to the life of {@link ExtensionList}. * If the manually registerd instances are scoped to VM level, the caller should pass in a static list. */ - protected ExtensionList(Hudson hudson, Class extensionType, List legacyStore) { + protected ExtensionList(Hudson hudson, Class extensionType, CopyOnWriteArrayList legacyStore) { this.hudson = hudson; this.extensionType = extensionType; this.legacyInstances = legacyStore; @@ -215,8 +216,8 @@ public class ExtensionList extends AbstractList { /** * Places to store static-scope legacy instances. */ - private static final Memoizer staticLegacyInstances = new Memoizer() { - public List compute(Class key) { + private static final Memoizer staticLegacyInstances = new Memoizer() { + public CopyOnWriteArrayList compute(Class key) { return new CopyOnWriteArrayList(); } };