Good catch Martin,
I think it is enough to put following into WebContextService, WDYT?
private void destroyRequestContext(ServletRequestEvent request)
{
.......
conversationContext.set(null);
conversationContext.remove();
}
________________________________
From: Martin Koci <[email protected]>
To: [email protected]
Sent: Sat, August 14, 2010 6:20:19 PM
Subject: WebBeansPhaseListener doesn't release ConversationContext for long
running conversation
Hi,
this use case probably leads to odd behaviour of conversation:
1) in first JSF request/response, in invoke application, I start long
running conversation with conversation.begin()
2) WebBeansPhaseListener.afterPhase(PhaseEvent) does some operation with
conversation object, but does not it **release** from ThreadLocal
3) then I create a GET request to other view in the same application but
without any operation with conversation,
WebBeansPhaseListener.afterPhase calls
ContextFactory.destroyConversationContext(); and destroys same instance
of ConversationContext because it is still in ThreadLocal!
I think WebBeansPhaseListener.afterPhase should contains something like
this:
else
{
//Conversation must be used by one thread at a time
ConversationImpl owbConversation = (ConversationImpl)conversation;
owbConversation.updateTimeOut();
//Other threads can now access propogated conversation.
owbConversation.setInUsed(false);
ContextFactory.releaseButNOTDestroyConversationContext();
}
What do you think?
Regards,
Martin Kočí