openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1688063 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
Date Sun, 28 Jun 2015 20:26:47 GMT
Author: rmannibucau
Date: Sun Jun 28 20:26:47 2015
New Revision: 1688063

URL: http://svn.apache.org/r1688063
Log:
OWB-1084 tracking session to get the right (from owb point of view) session instance for destroy
event

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java?rev=1688063&r1=1688062&r2=1688063&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
Sun Jun 28 20:26:47 2015
@@ -40,6 +40,11 @@ public class RequestContext extends Abst
      */
     private SessionContext propagatedSessionContext;
 
+    /**
+     * if propagatedSessionContext != null the event instance to use (http session can be
no more accessible)
+     */
+    private Object httpSession;
+
     /*
     * Constructor
     */
@@ -83,6 +88,15 @@ public class RequestContext extends Abst
         return propagatedSessionContext;
     }
 
+    public Object getHttpSession()
+    {
+        return httpSession;
+    }
+
+    public void setHttpSession(final Object httpSession)
+    {
+        this.httpSession = httpSession;
+    }
 
     @Override
     public void destroy(Contextual<?> contextual)

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java?rev=1688063&r1=1688062&r2=1688063&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
(original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
Sun Jun 28 20:26:47 2015
@@ -410,7 +410,12 @@ public class WebContextsService extends
             Object payload = null;
             if (context.getServletRequest() != null)
             {
-                payload = context.getServletRequest().getSession(false);
+                payload = context.getHttpSession();
+                if (payload == null)
+                {
+                    // in tomcat it will be null if invalidate was called
+                    payload = context.getServletRequest().getSession(false);
+                }
             }
 
             webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent(
@@ -552,6 +557,9 @@ public class WebContextsService extends
             else
             {
                 requestContext.setPropagatedSessionContext(context);
+                // this is to be spec compliant but depending the servlet container
+                // it can be dangerous if sessions are pooled (ie you can fire a session
used by another request)
+                requestContext.setHttpSession(session);
             }
         }
 



Mime
View raw message