Author: rmannibucau
Date: Wed Apr 24 08:37:13 2013
New Revision: 1471291

URL: http://svn.apache.org/r1471291
Log:
TOMEE-907 trying to ensure the session context exists when destroying it

Modified:
    
tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java

Modified: 
tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java?rev=1471291&r1=1471290&r2=1471291&view=diff
==============================================================================
--- 
tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
 (original)
+++ 
tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
 Wed Apr 24 08:37:13 2013
@@ -132,7 +132,6 @@ public class EndWebBeansListener impleme
                 elStore.destroyELContextStore();
             }
 
-
             
webBeansContext.getContextsService().endContext(RequestScoped.class, event);
             if (webBeansContext instanceof WebappWebBeansContext) { // end 
after child
                 ((WebappWebBeansContext) 
webBeansContext).getParent().getContextsService().endContext(RequestScoped.class,
 event);
@@ -172,9 +171,12 @@ public class EndWebBeansListener impleme
             logger.debug("Destroying a session with session id : [{0}]", 
event.getSession().getId());
         }
 
-        
this.webBeansContext.getContextsService().endContext(SessionScoped.class, 
event.getSession());
-        if (webBeansContext instanceof WebappWebBeansContext) { // end after 
child
-            ((WebappWebBeansContext) 
webBeansContext).getParent().getContextsService().endContext(SessionScoped.class,
 event.getSession());
+        // ensure session ThreadLocal is set
+        webBeansContext.getContextsService().startContext(SessionScoped.class, 
event.getSession());
+
+        webBeansContext.getContextsService().endContext(SessionScoped.class, 
event.getSession());
+        if (WebappWebBeansContext.class.isInstance(webBeansContext)) { // end 
after child
+            
WebappWebBeansContext.class.cast(webBeansContext).getParent().getContextsService().endContext(SessionScoped.class,
 event.getSession());
         }
 
         ConversationManager conversationManager = 
webBeansContext.getConversationManager();


Reply via email to