When the session is destroyed (e.g. due to logging out), then the current associated conversation is destroyed right away, in the session.invalidate(); call. Judging by the AbstractConversationContext#destroy code and comments, that's not intended:
for (ManagedConversation conversation : conversations.values()) {
|
String id = conversation.getId();
|
if (!conversation.isTransient()) {
|
// the currently associated conversation will be destroyed at the end of the current request
|
conversation.end();
|
}
|
if (!isCurrentConversation(id)) {
|
// a conversation that is not currently associated is destroyed immediately
|
destroyConversation(session, id);
|
}
|
}
|
The conversation.end call marks the current conversation as transient. Then isCurrentConversation wants to get the current conversation id:
return id !=null && id.equals(getCurrentConversation().getId());
|
But ConversationImpl#getId will return null, since it's transient now:
if (!_transient) {
|
return id;
|
} else {
|
return null;
|
}
|
Thus isCurrentConversation will return false, and the current conversation will be destroyed immediately. This is problematic if you intend to use the current conversation again before the request is over. Reproducer: weld conversation destroyed too early.zip .
|