You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by ka...@apache.org on 2012/10/03 07:07:42 UTC

git commit: FIXED - #TAP5-986: sendError in onActivate / Tapestry error dispatching - don't fire() the event if request's not available anymore

Updated Branches:
  refs/heads/5.3 35443aa07 -> acfdee71c


FIXED - #TAP5-986: sendError in onActivate / Tapestry error dispatching
- don't fire() the event if request's not available anymore


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/acfdee71
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/acfdee71
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/acfdee71

Branch: refs/heads/5.3
Commit: acfdee71c365ecff31b0a05d9bf27801a3a32d3c
Parents: 35443aa
Author: Kalle Korhonen <ka...@apache.org>
Authored: Tue Oct 2 22:03:09 2012 -0700
Committer: Kalle Korhonen <ka...@apache.org>
Committed: Tue Oct 2 22:06:15 2012 -0700

----------------------------------------------------------------------
 .../services/EndOfRequestEventHubImpl.java         |    9 ++++++++
 .../services/EndOfRequestEventHubImplTest.java     |   16 +++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/acfdee71/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImpl.java
index bd1bd21..a5743f9 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImpl.java
@@ -16,11 +16,18 @@ package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.internal.events.EndOfRequestListener;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry5.services.RequestGlobals;
 
 import java.util.List;
 
 public class EndOfRequestEventHubImpl implements EndOfRequestEventHub
 {
+    private final RequestGlobals requestGlobals;
+
+    public EndOfRequestEventHubImpl(RequestGlobals requestGlobals) {
+	this.requestGlobals = requestGlobals;
+    }
+
     private final List<EndOfRequestListener> listeners = CollectionFactory.newThreadSafeList();
 
     public void addEndOfRequestListener(EndOfRequestListener listener)
@@ -35,6 +42,8 @@ public class EndOfRequestEventHubImpl implements EndOfRequestEventHub
 
     public void fire()
     {
+        // TAP5-986: do not fire if request is already cleaned up. Container may use the same thread for different dispatches
+        if (requestGlobals.getRequest() == null) return;
         for (EndOfRequestListener l : listeners)
         {
             l.requestDidComplete();

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/acfdee71/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImplTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImplTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImplTest.java
index b910d97..35254cc 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImplTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EndOfRequestEventHubImplTest.java
@@ -16,14 +16,26 @@ package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.internal.events.EndOfRequestListener;
 import org.apache.tapestry5.internal.test.InternalBaseTestCase;
+import org.apache.tapestry5.services.Request;
+import org.apache.tapestry5.services.RequestGlobals;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 public class EndOfRequestEventHubImplTest extends InternalBaseTestCase
 {
+    private RequestGlobals globals = mockRequestGlobals();
+    private Request request = mockRequest();
+
+    @BeforeMethod
+    public void setup()
+    {
+        expect(globals.getRequest()).andReturn(request);
+    }
+
     @Test
     public void add_and_notify()
     {
-        EndOfRequestEventHub hub = new EndOfRequestEventHubImpl();
+        EndOfRequestEventHub hub = new EndOfRequestEventHubImpl(globals);
 
         EndOfRequestListener listener = newMock(EndOfRequestListener.class);
 
@@ -42,7 +54,7 @@ public class EndOfRequestEventHubImplTest extends InternalBaseTestCase
     @Test
     public void add_remove_notify()
     {
-        EndOfRequestEventHub hub = new EndOfRequestEventHubImpl();
+        EndOfRequestEventHub hub = new EndOfRequestEventHubImpl(globals);
 
         EndOfRequestListener listener = newMock(EndOfRequestListener.class);