You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by st...@apache.org on 2015/03/11 12:56:44 UTC

[28/50] tomee git commit: avoiding infinite loop with session listener in embedded mode

avoiding infinite loop with session listener in embedded mode


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4d0bf01a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4d0bf01a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4d0bf01a

Branch: refs/heads/master
Commit: 4d0bf01a91eef53699deb5a0306284af9ae84b39
Parents: 845fff2
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Mar 5 22:27:50 2015 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Mar 5 22:27:50 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/openejb/server/httpd/HttpRequestImpl.java    | 4 +++-
 .../java/org/apache/openejb/server/httpd/HttpSessionImpl.java    | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4d0bf01a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
index 2ac3b9b..804648d 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java
@@ -929,11 +929,13 @@ public class HttpRequestImpl implements HttpRequest {
                 }
             }
 
-            session = new HttpSessionImpl(SESSIONS, contextPath, timeout);
+            final HttpSessionImpl impl = new HttpSessionImpl(SESSIONS, contextPath, timeout);
+            session = impl;
             if (begin != null) {
                 begin.sessionCreated(new HttpSessionEvent(session));
                 session = new SessionInvalidateListener(session, end);
             }
+            impl.callListeners(); // can call req.getSession() so do it after affectation + do it after cdi init
 
             final RequestSession previous = SESSIONS.putIfAbsent(session.getId(), new RequestSession(this, session));
             if (previous != null) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/4d0bf01a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
index 6f06708..cd0a394 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpSessionImpl.java
@@ -50,6 +50,9 @@ public class HttpSessionImpl implements HttpSession {
         }
 
         this.listeners = LightweightWebAppBuilderListenerExtractor.findByTypeForContext(contextPath, HttpSessionListener.class);
+    }
+
+    public void callListeners() {
         if (!this.listeners.isEmpty()) {
             final HttpSessionEvent event = new HttpSessionEvent(this);
             for (final HttpSessionListener o : this.listeners) {