From ee58d02cbf4ea3dfd825aa0630e1d2696e87d01a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 19 Aug 2015 18:17:53 -0400 Subject: [PATCH] Use thread-safe list to store conversations While the methods manipulating or accessing the list are synchronized, the ConversationContainer class is also subject to serialization. Issue: SWF-1668 --- .../webflow/conversation/impl/ConversationContainer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java index df7bcc28..acfdf1cb 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java @@ -19,6 +19,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -37,6 +38,7 @@ import org.springframework.webflow.conversation.NoSuchConversationException; * {@link SessionBindingConversationManager}. * * @author Erwin Vervaet + * @author Rossen Stoyanchev */ public class ConversationContainer implements Serializable { @@ -63,7 +65,7 @@ public class ConversationContainer implements Serializable { public ConversationContainer(int maxConversations, String sessionKey) { this.maxConversations = maxConversations; this.sessionKey = sessionKey; - this.conversations = new ArrayList(); + this.conversations = new CopyOnWriteArrayList(); } /** @@ -135,7 +137,7 @@ public class ConversationContainer implements Serializable { for (Iterator it = conversations.iterator(); it.hasNext();) { ContainedConversation conversation = it.next(); if (conversation.getId().equals(id)) { - it.remove(); + conversations.remove(conversation); break; } }