浏览代码

DelegatingApplicationListener uses CopyOnWriteArrayList

Fixes gh-4416
Rob Winch 7 年之前
父节点
当前提交
38a8189a62

+ 2 - 2
core/src/main/java/org/springframework/security/context/DelegatingApplicationListener.java

@@ -20,8 +20,8 @@ import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.SmartApplicationListener;
 import org.springframework.context.event.SmartApplicationListener;
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
 
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 
 /**
 /**
  * Used for delegating to a number of SmartApplicationListener instances. This is useful
  * Used for delegating to a number of SmartApplicationListener instances. This is useful
@@ -32,7 +32,7 @@ import java.util.List;
  */
  */
 public final class DelegatingApplicationListener implements
 public final class DelegatingApplicationListener implements
 		ApplicationListener<ApplicationEvent> {
 		ApplicationListener<ApplicationEvent> {
-	private List<SmartApplicationListener> listeners = new ArrayList<SmartApplicationListener>();
+	private List<SmartApplicationListener> listeners = new CopyOnWriteArrayList<>();
 
 
 	public void onApplicationEvent(ApplicationEvent event) {
 	public void onApplicationEvent(ApplicationEvent event) {
 		if (event == null) {
 		if (event == null) {