@@ -201,27 +201,31 @@ public void finalEndConversation(Conversation conversation, ConversationEndingTy
201
201
* org.springframework.conversation.JoinMode)
202
202
*/
203
203
public Conversation beginConversation (boolean temporary , JoinMode joinMode ) {
204
- // create a new conversation and initialize it
205
- MutableConversation newConversation = createNewConversation ();
204
+ ConversationResolver resolver = getConversationResolver ();
205
+ ConversationStore store = getConversationStore ();
206
+ MutableConversation currentConversation = silentlyCastConversation (getCurrentConversation ());
207
+ MutableConversation newConversation = null ;
206
208
207
- // set the default timeout according the setup of this manager
208
- newConversation .setTimeout (getDefaultConversationTimeout ());
209
+ if (currentConversation == null || !joinMode .mustBeJoined ()) {
210
+ // create a new conversation and initialize it
211
+ newConversation = createNewConversation ();
209
212
210
- // set the temporary flag of the newly created conversation and also
211
- // assign it a newly created, unique id
212
- newConversation .setTemporary (temporary );
213
- newConversation .setId (createNewConversationId ());
213
+ // set the default timeout according the setup of this manager
214
+ newConversation .setTimeout (getDefaultConversationTimeout ());
214
215
215
- ConversationResolver resolver = getConversationResolver ();
216
- ConversationStore store = getConversationStore ();
217
- store .registerConversation (newConversation );
216
+ // set the temporary flag of the newly created conversation and also
217
+ // assign it a newly created, unique id
218
+ newConversation .setTemporary (temporary );
219
+ newConversation .setId (createNewConversationId ());
218
220
219
- MutableConversation currentConversation = silentlyCastConversation (getCurrentConversation ());
221
+ store .registerConversation (newConversation );
222
+ }
220
223
221
224
// check, if there is a current conversation
222
225
if (currentConversation != null ) {
223
226
if (joinMode .mustBeJoined ()) {
224
227
currentConversation .joinConversation ();
228
+ return currentConversation ;
225
229
}
226
230
227
231
if (joinMode .mustBeSwitched ()) {
@@ -248,8 +252,8 @@ public Conversation beginConversation(boolean temporary, JoinMode joinMode) {
248
252
}
249
253
}
250
254
251
- // make the newly created conversation the current one, invoke listeners
252
- // and return it
255
+ // make the newly created conversation the current one, invoke
256
+ // listeners and return it
253
257
resolver .setCurrentConversationId (newConversation .getId ());
254
258
newConversation .activated (joinMode .mustBeSwitched () ? ConversationActivationType .SWITCHED
255
259
: ConversationActivationType .NEW , currentConversation );
0 commit comments