camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1164450 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java
Date Fri, 02 Sep 2011 09:51:41 GMT
Author: davsclaus
Date: Fri Sep  2 09:51:41 2011
New Revision: 1164450

URL: http://svn.apache.org/viewvc?rev=1164450&view=rev
Log:
Merged revisions 1149570 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk


Added:
    camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java
      - copied unchanged from r1149570, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  2 09:51:41 2011
@@ -1 +1 @@
-/camel/trunk:1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395
+/camel/trunk:1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java?rev=1164450&r1=1164449&r2=1164450&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
(original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
Fri Sep  2 09:51:41 2011
@@ -93,7 +93,7 @@ public class TraceInterceptor extends De
     }
 
     @Override
-    public boolean process(Exchange exchange, AsyncCallback callback) {
+    public boolean process(final Exchange exchange, final AsyncCallback callback) {
         // do not trace if tracing is disabled
         if (!tracer.isEnabled() || (routeContext != null && !routeContext.isTracing()))
{
             return super.process(exchange, callback);
@@ -106,7 +106,7 @@ public class TraceInterceptor extends De
             return super.process(exchange, callback);
         }
 
-        boolean shouldLog = shouldLogNode(node) && shouldLogExchange(exchange);
+        final boolean shouldLog = shouldLogNode(node) && shouldLogExchange(exchange);
 
         // whether we should trace it or not, some nodes should be skipped as they are abstract
         // intermediate steps for instance related to on completion
@@ -149,37 +149,47 @@ public class TraceInterceptor extends De
             }
 
             // log and trace the processor
-            Object traceState = null;
+            Object state = null;
             if (shouldLog && trace) {
                 logExchange(exchange);
                 // either call the in or generic trace method depending on OUT has been enabled
or not
                 if (tracer.isTraceOutExchanges()) {
-                    traceState = traceExchangeIn(exchange);
+                    state = traceExchangeIn(exchange);
                 } else {
                     traceExchange(exchange);
                 }
             }
+            final Object traceState = state;
 
-            try {
-                // special for interceptor where we need to keep booking how far we have
routed in the intercepted processors
-                if (node.getParent() instanceof InterceptDefinition && exchange.getUnitOfWork()
!= null) {
-                    TracedRouteNodes traced = exchange.getUnitOfWork().getTracedRouteNodes();
-                    traceIntercept((InterceptDefinition) node.getParent(), traced, exchange);
-                }
+            // special for interceptor where we need to keep booking how far we have routed
in the intercepted processors
+            if (node.getParent() instanceof InterceptDefinition && exchange.getUnitOfWork()
!= null) {
+                TracedRouteNodes traced = exchange.getUnitOfWork().getTracedRouteNodes();
+                traceIntercept((InterceptDefinition) node.getParent(), traced, exchange);
+            }
 
-                // process the exchange
-                try {
-                    sync = super.process(exchange, callback);
-                } catch (Throwable e) {
-                    exchange.setException(e);
-                }
-            } finally {
-                // after (trace out)
-                if (shouldLog && tracer.isTraceOutExchanges()) {
-                    logExchange(exchange);
-                    traceExchangeOut(exchange, traceState);
+            // process the exchange
+            sync = super.process(exchange, new AsyncCallback() {
+                @Override
+                public void done(boolean doneSync) {
+                    try {
+                        // after (trace out)
+                        if (shouldLog && tracer.isTraceOutExchanges()) {
+                            logExchange(exchange);
+                            traceExchangeOut(exchange, traceState);
+                        }
+                    } catch (Throwable e) {
+                        // some exception occurred in trace logic
+                        if (shouldLogException(exchange)) {
+                            logException(exchange, e);
+                        }
+                        exchange.setException(e);
+                    } finally {
+                        // ensure callback is always invoked
+                        callback.done(doneSync);
+                    }
                 }
-            }
+            });
+
         } catch (Throwable e) {
             // some exception occurred in trace logic
             if (shouldLogException(exchange)) {



Mime
View raw message