Skip to content

Commit 6e466f4

Browse files
author
Micha Kiener
committed
SPR-6419, manager implementation
1 parent e55ad99 commit 6e466f4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

org.springframework.context/src/main/java/org/springframework/conversation/manager/ConversationManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ <T extends ConversationType> Conversation beginConversation(JoinMode joinMode, T
177177
* @param endingType the type qualifying on how this conversation is to be
178178
* ended (only passed on to any listeners, does not have an impact on the
179179
* conversation manager)
180+
* @throws IllegalStateException if the given conversation has a nested
181+
* conversation which is not ended which is an illegal condition
180182
*/
181183
void endConversation(Conversation conversation, ConversationEndingType endingType);
182184

org.springframework.context/src/main/java/org/springframework/conversation/manager/ConversationManagerImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,16 @@ public Conversation endCurrentConversation(ConversationEndingType endingType) {
116116
* org.springframework.conversation.ConversationEndingType)
117117
*/
118118
public void endConversation(Conversation conversation, ConversationEndingType endingType) {
119+
MutableConversation c = silentlyCastConversation(conversation);
120+
if (c.isParent()) {
121+
throw new IllegalStateException(
122+
"Illegal attempt to end a conversation, still having a nested, active conversation.");
123+
}
124+
119125
ConversationResolver resolver = getConversationResolver();
120126
String currentId = resolver.getCurrentConversationId();
121127
boolean wasCurrent = (currentId != null && currentId.equals(conversation.getId()));
122128

123-
MutableConversation c = silentlyCastConversation(conversation);
124-
125129
// let the conversation object end (this will invoke any listeners too,
126130
// if the conversation was finally ended)
127131
c.internallyEndConversation(endingType);
@@ -146,7 +150,6 @@ public void endConversation(Conversation conversation, ConversationEndingType en
146150
resolver.setCurrentConversationId(null);
147151
}
148152
}
149-
150153
}
151154

152155
// invoke ending hook

0 commit comments

Comments
 (0)