Repository: tapestry-5 Updated Branches: refs/heads/master 2482d6698 -> 3ed6c858c
FIXED - TAP5-2396: DefaultExceptionHandler doesn't currently recognize TapestryException - unwrap all exceptions of type TapestryException to find the specific/root cause exception - fix test to use a wrapped exception Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/3ed6c858 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/3ed6c858 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/3ed6c858 Branch: refs/heads/master Commit: 3ed6c858c18090ee159ededdd735c41e2065193a Parents: 2482d66 Author: kaosko <kao...@apache.org> Authored: Wed Oct 8 09:41:06 2014 -0700 Committer: kaosko <kao...@apache.org> Committed: Wed Oct 8 09:41:06 2014 -0700 ---------------------------------------------------------------------- .../internal/services/DefaultRequestExceptionHandler.java | 4 +++- .../internal/services/DefaultRequestExceptionHandlerTest.java | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3ed6c858/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java index 2e69878..5923dfb 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.java @@ -21,6 +21,7 @@ import org.apache.tapestry5.internal.structure.Page; import org.apache.tapestry5.ioc.ServiceResources; import org.apache.tapestry5.ioc.annotations.Symbol; import org.apache.tapestry5.ioc.internal.OperationException; +import org.apache.tapestry5.ioc.internal.util.TapestryException; import org.apache.tapestry5.ioc.util.ExceptionUtils; import org.apache.tapestry5.json.JSONObject; import org.apache.tapestry5.runtime.ComponentEventException; @@ -28,6 +29,7 @@ import org.apache.tapestry5.services.*; import org.slf4j.Logger; import javax.servlet.http.HttpServletResponse; + import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; @@ -151,7 +153,7 @@ public class DefaultRequestExceptionHandler implements RequestExceptionHandler // For exceptions in component operations, it's OperationException -> ComponentEventException -> <Target>Exception // Throw away the wrapped exceptions first - while (cause instanceof OperationException || cause instanceof ComponentEventException) + while (cause instanceof TapestryException) { if (cause.getCause() == null) break; cause = cause.getCause(); http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3ed6c858/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandlerTest.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandlerTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandlerTest.java index ed9517c..5cfd190 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandlerTest.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandlerTest.java @@ -17,6 +17,8 @@ import org.apache.tapestry5.ExceptionHandlerAssistant; import org.apache.tapestry5.Link; import org.apache.tapestry5.internal.test.InternalBaseTestCase; import org.apache.tapestry5.ioc.ServiceResources; +import org.apache.tapestry5.ioc.internal.OperationException; +import org.apache.tapestry5.ioc.internal.util.TapestryException; import org.apache.tapestry5.services.ComponentClassResolver; import org.apache.tapestry5.services.ExceptionReporter; import org.apache.tapestry5.services.Request; @@ -159,7 +161,10 @@ public class DefaultRequestExceptionHandlerTest extends InternalBaseTestCase EasyMock.expectLastCall(); replay(); - exceptionHandler.handleRequestException(new AccessControlException("No permission")); + // also test unwrapping TapestryExceptions + exceptionHandler.handleRequestException(new OperationException(new RenderQueueException( + "renderqueue", new Object[0], new TapestryException("tapestryexception", + new AccessControlException("No permission"))), new String[0])); } @Test