Skip to content

Commit ee58d02

Browse files
committed
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
1 parent f4d07d8 commit ee58d02

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.Iterator;
2121
import java.util.List;
22+
import java.util.concurrent.CopyOnWriteArrayList;
2223

2324
import org.apache.commons.logging.Log;
2425
import org.apache.commons.logging.LogFactory;
@@ -37,6 +38,7 @@
3738
* {@link SessionBindingConversationManager}.
3839
*
3940
* @author Erwin Vervaet
41+
* @author Rossen Stoyanchev
4042
*/
4143
public class ConversationContainer implements Serializable {
4244

@@ -63,7 +65,7 @@ public class ConversationContainer implements Serializable {
6365
public ConversationContainer(int maxConversations, String sessionKey) {
6466
this.maxConversations = maxConversations;
6567
this.sessionKey = sessionKey;
66-
this.conversations = new ArrayList<ContainedConversation>();
68+
this.conversations = new CopyOnWriteArrayList<ContainedConversation>();
6769
}
6870

6971
/**
@@ -135,7 +137,7 @@ public synchronized void removeConversation(ConversationId id) {
135137
for (Iterator<ContainedConversation> it = conversations.iterator(); it.hasNext();) {
136138
ContainedConversation conversation = it.next();
137139
if (conversation.getId().equals(id)) {
138-
it.remove();
140+
conversations.remove(conversation);
139141
break;
140142
}
141143
}

0 commit comments

Comments
 (0)