Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B098985B for ; Mon, 20 May 2013 10:19:45 +0000 (UTC) Received: (qmail 54596 invoked by uid 500); 20 May 2013 10:19:43 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 54408 invoked by uid 500); 20 May 2013 10:19:38 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 54339 invoked by uid 99); 20 May 2013 10:19:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 May 2013 10:19:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 47C4E319FE7; Mon, 20 May 2013 10:19:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Mon, 20 May 2013 10:19:38 -0000 Message-Id: <03cc22e71cd24a1787077c6fbdb3e15a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/5] git commit: CAMEL-6377: Optimized routing engine to reduce stack frames in use during routing. Work in progress. CAMEL-6377: Optimized routing engine to reduce stack frames in use during routing. Work in progress. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6848de70 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6848de70 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6848de70 Branch: refs/heads/master Commit: 6848de70da245c1df06c0bdc12f55f044b7bbfd5 Parents: ee5487e Author: Claus Ibsen Authored: Mon May 20 11:25:40 2013 +0200 Committer: Claus Ibsen Committed: Mon May 20 11:25:40 2013 +0200 ---------------------------------------------------------------------- .../camel/processor/CamelInternalProcessor.java | 25 +++++++++------ .../ReduceStacksNeededDuringRoutingTest.java | 4 +- 2 files changed, 17 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/6848de70/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java index 52c6807..5e73115 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java +++ b/camel-core/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java @@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory; *
    *
  • Keeping track which route currently is being routed
  • *
  • Gather JMX performance statics
  • - *
  • Tracing the routing using
  • + *
  • Tracing
  • *
  • Execute {@link RoutePolicy}
  • *
* ... and much more. @@ -112,6 +112,7 @@ public final class CamelInternalProcessor extends DelegateAsyncProcessor { } } + // create internal callback which will execute the tasks in reverse order when done callback = new InternalCallback(states, exchange, callback); if (exchange.isTransacted()) { @@ -164,17 +165,21 @@ public final class CamelInternalProcessor extends DelegateAsyncProcessor { @Override public void done(boolean doneSync) { // we should call after in reverse order - for (int i = tasks.size() - 1; i >= 0; i--) { - CamelInternalProcessorTask task = tasks.get(i); - Object state = states.get(i); - try { - task.after(exchange, state); - } catch (Throwable e) { - exchange.setException(e); - break; + try { + for (int i = tasks.size() - 1; i >= 0; i--) { + CamelInternalProcessorTask task = tasks.get(i); + Object state = states.get(i); + try { + task.after(exchange, state); + } catch (Exception e) { + exchange.setException(e); + // allow all tasks to complete even if there was an exception + } } + } finally { + // callback must be called + callback.done(doneSync); } - callback.done(doneSync); } } http://git-wip-us.apache.org/repos/asf/camel/blob/6848de70/camel-core/src/test/java/org/apache/camel/processor/ReduceStacksNeededDuringRoutingTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/ReduceStacksNeededDuringRoutingTest.java b/camel-core/src/test/java/org/apache/camel/processor/ReduceStacksNeededDuringRoutingTest.java index 3edebe4..e6b4a6c 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ReduceStacksNeededDuringRoutingTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ReduceStacksNeededDuringRoutingTest.java @@ -54,7 +54,7 @@ public class ReduceStacksNeededDuringRoutingTest extends ContextTestSupport { try { throw new IllegalArgumentException("Forced to dump stacktrace"); } catch (Exception e) { - e.printStackTrace(); + log.error("Dump stacktrace to log", e); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); @@ -68,7 +68,7 @@ public class ReduceStacksNeededDuringRoutingTest extends ContextTestSupport { scanner.next(); count++; } - System.out.println("There is " + count + " lines in the stacktrace"); + log.info("There is " + count + " lines in the stacktrace"); } } })