You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2016/04/24 20:38:27 UTC

[10/12] wicket git commit: WICKET-6129 move duplicated code into #executeExceptionRequestHandler

WICKET-6129 move duplicated code into #executeExceptionRequestHandler


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/71f22026
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/71f22026
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/71f22026

Branch: refs/heads/master
Commit: 71f220266550eb5b6514400e3daa34eed9607a54
Parents: 80562f9
Author: Sven Meier <sv...@apache.org>
Authored: Fri Apr 8 23:14:43 2016 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Sun Apr 24 20:00:54 2016 +0200

----------------------------------------------------------------------
 .../wicket/request/cycle/RequestCycle.java      | 30 ++++++++------------
 .../request/cycle/RequestCycleListenerTest.java |  4 ++-
 2 files changed, 15 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/71f22026/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java b/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
index 075bda8..f92e024 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
@@ -254,15 +254,7 @@ public class RequestCycle implements IRequestCycle, IEventSink
 		}
 		catch (Exception exception)
 		{
-			IRequestHandler handler = handleException(exception);
-			if (handler != null)
-			{
-				executeExceptionRequestHandler(exception, handler, getExceptionRetryCount());
-			}
-			else
-			{
-				log.error("Error during request processing. URL=" + request.getUrl(), exception);
-			}
+			executeExceptionRequestHandler(exception, getExceptionRetryCount());
 			return true;
 		}
 		finally
@@ -311,15 +303,22 @@ public class RequestCycle implements IRequestCycle, IEventSink
 	}
 
 	/**
+	 * Execute a requestHandler for the given exception.
 	 * 
 	 * @param exception
-	 * @param handler
 	 * @param retryCount
 	 */
-	private void executeExceptionRequestHandler(Exception exception, final IRequestHandler handler, int retryCount)
+	private void executeExceptionRequestHandler(Exception exception, int retryCount)
 	{
 		scheduleRequestHandlerAfterCurrent(null);
 
+		IRequestHandler handler = handleException(exception);
+		if (handler == null)
+		{
+			log.error("Error during request processing. URL=" + request.getUrl(), exception);
+			return;
+		}
+
 		try
 		{
 			listeners.onExceptionRequestHandlerResolved(this, handler, exception);
@@ -330,16 +329,11 @@ public class RequestCycle implements IRequestCycle, IEventSink
 		{
 			if (retryCount <= 0)
 			{
-				log.error("Error during executing exception request handler", e);
+				log.error("Exception retry count exceeded", e);
 			}
 			else
 			{
-				IRequestHandler next = handleException(e);
-				if (next != null)
-				{
-					executeExceptionRequestHandler(exception, next, retryCount - 1);
-					return;
-				}
+				executeExceptionRequestHandler(exception, retryCount - 1);
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/71f22026/wicket-core/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java b/wicket-core/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
index e754a77..e0901e1 100644
--- a/wicket-core/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/request/cycle/RequestCycleListenerTest.java
@@ -247,6 +247,8 @@ public class RequestCycleListenerTest extends BaseRequestHandlerStackTest
 		cycle.processRequestAndDetach();
 
 		assertEquals(401, errorCode);
+		assertEquals(2, incrementingListener.resolved);
+		assertEquals(1, incrementingListener.executed);
 		assertEquals(1, incrementingListener.exceptionResolutions);
 		assertEquals(0, incrementingListener.schedules);
 	}
@@ -270,7 +272,7 @@ public class RequestCycleListenerTest extends BaseRequestHandlerStackTest
 	 * @throws Exception
 	 */
 	@Test
-	public void exceptionHandingInOnDetach() throws Exception
+	public void exceptionHandlingInOnDetach() throws Exception
 	{
 		// this test is a little flaky because it depends on the ordering of listeners which is not
 		// guaranteed