camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/5] git commit: CAMEL-6377: Optimized routing engine to reduce stack frames in use during routing. Work in progress.
Date Mon, 20 May 2013 10:19:38 GMT
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 <davsclaus@apache.org>
Authored: Mon May 20 11:25:40 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
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;
  * <ul>
  *     <li>Keeping track which route currently is being routed</li>
  *     <li>Gather JMX performance statics</li>
- *     <li>Tracing the routing using</li>
+ *     <li>Tracing</li>
  *     <li>Execute {@link RoutePolicy}</li>
  * </ul>
  * ... 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");
                                 }
                             }
                         })


Mime
View raw message