Repository: camel
Updated Branches:
  refs/heads/master e033ad2bb -> b97c03070


CAMEL-11360: Disable Tracer and use BacklogTracer instead


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/629b4c01
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/629b4c01
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/629b4c01

Branch: refs/heads/master
Commit: 629b4c0187a926799db87b212859f0ebbf7c9a90
Parents: e033ad2
Author: Claus Ibsen <[email protected]>
Authored: Mon May 29 16:10:28 2017 +0200
Committer: Claus Ibsen <[email protected]>
Committed: Mon May 29 16:10:28 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultUnitOfWork.java    |   7 +-
 .../camel/processor/MulticastProcessor.java     | 185 ++++++++-----------
 .../processor/interceptor/DefaultChannel.java   |  45 -----
 .../interceptor/DefaultTraceEventHandler.java   |   1 +
 .../interceptor/DefaultTraceEventMessage.java   |  12 +-
 .../interceptor/DefaultTraceFormatter.java      |  33 ++--
 .../processor/interceptor/TraceInterceptor.java |  49 ++---
 .../processor/TraceableUnitOfWorkTest.java      |   3 +
 8 files changed, 136 insertions(+), 199 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
index f8f0971..f725859 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
@@ -63,7 +63,6 @@ public class DefaultUnitOfWork implements UnitOfWork, Service 
{
     private CamelContext context;
     private List<Synchronization> synchronizations;
     private Message originalInMessage;
-    private final TracedRouteNodes tracedRouteNodes;
     private Set<Object> transactedBy;
     private final Stack<RouteContext> routeContextStack = new 
Stack<RouteContext>();
     private Stack<DefaultSubUnitOfWork> subUnitOfWorks;
@@ -78,7 +77,6 @@ public class DefaultUnitOfWork implements UnitOfWork, Service 
{
         if (log.isTraceEnabled()) {
             log.trace("UnitOfWork created for ExchangeId: {} with {}", 
exchange.getExchangeId(), exchange);
         }
-        tracedRouteNodes = new DefaultTracedRouteNodes();
         context = exchange.getContext();
 
         if (context.isAllowUseOriginalMessage()) {
@@ -162,9 +160,6 @@ public class DefaultUnitOfWork implements UnitOfWork, 
Service {
         if (synchronizations != null) {
             synchronizations.clear();
         }
-        if (tracedRouteNodes != null) {
-            tracedRouteNodes.clear();
-        }
         if (transactedBy != null) {
             transactedBy.clear();
         }
@@ -298,7 +293,7 @@ public class DefaultUnitOfWork implements UnitOfWork, 
Service {
     }
 
     public TracedRouteNodes getTracedRouteNodes() {
-        return tracedRouteNodes;
+        return null;
     }
 
     public boolean isTransacted() {

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java 
b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index 896372b..1873f82 100644
--- 
a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ 
b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -675,52 +675,92 @@ public class MulticastProcessor extends ServiceSupport 
implements AsyncProcessor
         Processor processor = pair.getProcessor();
         final Producer producer = pair.getProducer();
 
-        TracedRouteNodes traced = exchange.getUnitOfWork() != null ? 
exchange.getUnitOfWork().getTracedRouteNodes() : null;
-
-        try {
-            // prepare tracing starting from a new block
-            if (traced != null) {
-                traced.pushBlock();
+        StopWatch sw = null;
+        if (producer != null) {
+            boolean sending = 
EventHelper.notifyExchangeSending(exchange.getContext(), exchange, 
producer.getEndpoint());
+            if (sending) {
+                sw = new StopWatch();
             }
+        }
 
-            StopWatch sw = null;
-            if (producer != null) {
-                boolean sending = 
EventHelper.notifyExchangeSending(exchange.getContext(), exchange, 
producer.getEndpoint());
-                if (sending) {
-                    sw = new StopWatch();
+        // compute time taken if sending to another endpoint
+        final StopWatch watch = sw;
+
+        // let the prepared process it, remember to begin the exchange pair
+        AsyncProcessor async = 
AsyncProcessorConverterHelper.convert(processor);
+        pair.begin();
+        sync = async.process(exchange, new AsyncCallback() {
+            public void done(boolean doneSync) {
+                // we are done with the exchange pair
+                pair.done();
+
+                // okay we are done, so notify the exchange was sent
+                if (producer != null && watch != null) {
+                    long timeTaken = watch.taken();
+                    Endpoint endpoint = producer.getEndpoint();
+                    // emit event that the exchange was sent to the endpoint
+                    EventHelper.notifyExchangeSent(exchange.getContext(), 
exchange, endpoint, timeTaken);
                 }
-            }
 
-            // compute time taken if sending to another endpoint
-            final StopWatch watch = sw;
+                // we only have to handle async completion of the routing slip
+                if (doneSync) {
+                    return;
+                }
 
-            // let the prepared process it, remember to begin the exchange pair
-            AsyncProcessor async = 
AsyncProcessorConverterHelper.convert(processor);
-            pair.begin();
-            sync = async.process(exchange, new AsyncCallback() {
-                public void done(boolean doneSync) {
-                    // we are done with the exchange pair
-                    pair.done();
-
-                    // okay we are done, so notify the exchange was sent
-                    if (producer != null && watch != null) {
-                        long timeTaken = watch.taken();
-                        Endpoint endpoint = producer.getEndpoint();
-                        // emit event that the exchange was sent to the 
endpoint
-                        EventHelper.notifyExchangeSent(exchange.getContext(), 
exchange, endpoint, timeTaken);
+                // continue processing the multicast asynchronously
+                Exchange subExchange = exchange;
+
+                // Decide whether to continue with the multicast or not; 
similar logic to the Pipeline
+                // remember to test for stop on exception and aggregate before 
copying back results
+                boolean continueProcessing = 
PipelineHelper.continueProcessing(subExchange, "Sequential processing failed 
for number " + total.get(), LOG);
+                if (stopOnException && !continueProcessing) {
+                    if (subExchange.getException() != null) {
+                        // wrap in exception to explain where it failed
+                        subExchange.setException(new 
CamelExchangeException("Sequential processing failed for number " + total, 
subExchange, subExchange.getException()));
+                    } else {
+                        // we want to stop on exception, and the exception was 
handled by the error handler
+                        // this is similar to what the pipeline does, so we 
should do the same to not surprise end users
+                        // so we should set the failed exchange as the result 
and be done
+                        result.set(subExchange);
                     }
+                    // and do the done work
+                    doDone(original, subExchange, pairs, callback, false, 
true);
+                    return;
+                }
 
-                    // we only have to handle async completion of the routing 
slip
-                    if (doneSync) {
-                        return;
+                try {
+                    if (parallelAggregate) {
+                        
doAggregateInternal(getAggregationStrategy(subExchange), result, subExchange);
+                    } else {
+                        doAggregate(getAggregationStrategy(subExchange), 
result, subExchange);
                     }
+                } catch (Throwable e) {
+                    // wrap in exception to explain where it failed
+                    subExchange.setException(new 
CamelExchangeException("Sequential processing failed for number " + total, 
subExchange, e));
+                    // and do the done work
+                    doDone(original, subExchange, pairs, callback, false, 
true);
+                    return;
+                }
+
+                total.incrementAndGet();
 
-                    // continue processing the multicast asynchronously
-                    Exchange subExchange = exchange;
+                // maybe there are more processors to multicast
+                while (it.hasNext()) {
+
+                    // prepare and run the next
+                    ProcessorExchangePair pair = it.next();
+                    subExchange = pair.getExchange();
+                    updateNewExchange(subExchange, total.get(), pairs, it);
+                    boolean sync = doProcessSequential(original, result, 
pairs, it, pair, callback, total);
+
+                    if (!sync) {
+                        LOG.trace("Processing exchangeId: {} is continued 
being processed asynchronously", original.getExchangeId());
+                        return;
+                    }
 
                     // Decide whether to continue with the multicast or not; 
similar logic to the Pipeline
                     // remember to test for stop on exception and aggregate 
before copying back results
-                    boolean continueProcessing = 
PipelineHelper.continueProcessing(subExchange, "Sequential processing failed 
for number " + total.get(), LOG);
+                    continueProcessing = 
PipelineHelper.continueProcessing(subExchange, "Sequential processing failed 
for number " + total.get(), LOG);
                     if (stopOnException && !continueProcessing) {
                         if (subExchange.getException() != null) {
                             // wrap in exception to explain where it failed
@@ -736,6 +776,7 @@ public class MulticastProcessor extends ServiceSupport 
implements AsyncProcessor
                         return;
                     }
 
+                    // must catch any exceptions from aggregation
                     try {
                         if (parallelAggregate) {
                             
doAggregateInternal(getAggregationStrategy(subExchange), result, subExchange);
@@ -751,68 +792,13 @@ public class MulticastProcessor extends ServiceSupport 
implements AsyncProcessor
                     }
 
                     total.incrementAndGet();
-
-                    // maybe there are more processors to multicast
-                    while (it.hasNext()) {
-
-                        // prepare and run the next
-                        ProcessorExchangePair pair = it.next();
-                        subExchange = pair.getExchange();
-                        updateNewExchange(subExchange, total.get(), pairs, it);
-                        boolean sync = doProcessSequential(original, result, 
pairs, it, pair, callback, total);
-
-                        if (!sync) {
-                            LOG.trace("Processing exchangeId: {} is continued 
being processed asynchronously", original.getExchangeId());
-                            return;
-                        }
-
-                        // Decide whether to continue with the multicast or 
not; similar logic to the Pipeline
-                        // remember to test for stop on exception and 
aggregate before copying back results
-                        continueProcessing = 
PipelineHelper.continueProcessing(subExchange, "Sequential processing failed 
for number " + total.get(), LOG);
-                        if (stopOnException && !continueProcessing) {
-                            if (subExchange.getException() != null) {
-                                // wrap in exception to explain where it failed
-                                subExchange.setException(new 
CamelExchangeException("Sequential processing failed for number " + total, 
subExchange, subExchange.getException()));
-                            } else {
-                                // we want to stop on exception, and the 
exception was handled by the error handler
-                                // this is similar to what the pipeline does, 
so we should do the same to not surprise end users
-                                // so we should set the failed exchange as the 
result and be done
-                                result.set(subExchange);
-                            }
-                            // and do the done work
-                            doDone(original, subExchange, pairs, callback, 
false, true);
-                            return;
-                        }
-
-                        // must catch any exceptions from aggregation
-                        try {
-                            if (parallelAggregate) {
-                                
doAggregateInternal(getAggregationStrategy(subExchange), result, subExchange);
-                            } else {
-                                
doAggregate(getAggregationStrategy(subExchange), result, subExchange);
-                            }
-                        } catch (Throwable e) {
-                            // wrap in exception to explain where it failed
-                            subExchange.setException(new 
CamelExchangeException("Sequential processing failed for number " + total, 
subExchange, e));
-                            // and do the done work
-                            doDone(original, subExchange, pairs, callback, 
false, true);
-                            return;
-                        }
-
-                        total.incrementAndGet();
-                    }
-
-                    // do the done work
-                    subExchange = result.get() != null ? result.get() : null;
-                    doDone(original, subExchange, pairs, callback, false, 
true);
                 }
-            });
-        } finally {
-            // pop the block so by next round we have the same staring point 
and thus the tracing looks accurate
-            if (traced != null) {
-                traced.popBlock();
+
+                // do the done work
+                subExchange = result.get() != null ? result.get() : null;
+                doDone(original, subExchange, pairs, callback, false, true);
             }
-        }
+        });
 
         return sync;
     }
@@ -822,16 +808,9 @@ public class MulticastProcessor extends ServiceSupport 
implements AsyncProcessor
         Processor processor = pair.getProcessor();
         Producer producer = pair.getProducer();
 
-        TracedRouteNodes traced = exchange.getUnitOfWork() != null ? 
exchange.getUnitOfWork().getTracedRouteNodes() : null;
-
         // compute time taken if sending to another endpoint
         StopWatch watch = null;
         try {
-            // prepare tracing starting from a new block
-            if (traced != null) {
-                traced.pushBlock();
-            }
-
             if (producer != null) {
                 boolean sending = 
EventHelper.notifyExchangeSending(exchange.getContext(), exchange, 
producer.getEndpoint());
                 if (sending) {
@@ -845,10 +824,6 @@ public class MulticastProcessor extends ServiceSupport 
implements AsyncProcessor
             AsyncProcessorHelper.process(async, exchange);
         } finally {
             pair.done();
-            // pop the block so by next round we have the same staring point 
and thus the tracing looks accurate
-            if (traced != null) {
-                traced.popBlock();
-            }
             if (producer != null && watch != null) {
                 Endpoint endpoint = producer.getEndpoint();
                 long timeTaken = watch.taken();

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
index e789ab1..a88bd71 100644
--- 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
+++ 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
@@ -247,18 +247,6 @@ public class DefaultChannel extends CamelInternalProcessor 
implements ModelChann
             addAdvice(new MessageHistoryAdvice(factory, targetOutputDef));
         }
 
-        // the regular tracer is not a task on internalProcessor as this is 
not really needed
-        // end users have to explicit enable the tracer to use it, and then 
its okay if we wrap
-        // the processors (but by default tracer is disabled, and therefore we 
do not wrap processors)
-        tracer = getOrCreateTracer();
-        camelContext.addService(tracer);
-        if (tracer != null) {
-            TraceInterceptor trace = (TraceInterceptor) 
tracer.wrapProcessorInInterceptors(routeContext.getCamelContext(), 
targetOutputDef, target, null);
-            // trace interceptor need to have a reference to route context so 
we at runtime can enable/disable tracing on-the-fly
-            trace.setRouteContext(routeContext);
-            target = trace;
-        }
-
         // sort interceptors according to ordered
         interceptors.sort(OrderedComparator.get());
         // then reverse list so the first will be wrapped last, as it would 
then be first being invoked
@@ -320,39 +308,6 @@ public class DefaultChannel extends CamelInternalProcessor 
implements ModelChann
         // noop
     }
 
-    private InterceptStrategy getOrCreateTracer() {
-        // only use tracer if explicit enabled
-        if (camelContext.isTracing() != null && !camelContext.isTracing()) {
-            return null;
-        }
-
-        InterceptStrategy tracer = Tracer.getTracer(camelContext);
-        if (tracer == null) {
-            if (camelContext.getRegistry() != null) {
-                // lookup in registry
-                Map<String, Tracer> map = 
camelContext.getRegistry().findByTypeWithName(Tracer.class);
-                if (map.size() == 1) {
-                    tracer = map.values().iterator().next();
-                }
-            }
-            if (tracer == null) {
-                // fallback to use the default tracer
-                tracer = camelContext.getDefaultTracer();
-
-                // configure and use any trace formatter if any exists
-                Map<String, TraceFormatter> formatters = 
camelContext.getRegistry().findByTypeWithName(TraceFormatter.class);
-                if (formatters.size() == 1) {
-                    TraceFormatter formatter = 
formatters.values().iterator().next();
-                    if (tracer instanceof Tracer) {
-                        ((Tracer) tracer).setFormatter(formatter);
-                    }
-                }
-            }
-        }
-
-        return tracer;
-    }
-
     private InterceptStrategy getOrCreateBacklogTracer() {
         InterceptStrategy tracer = 
BacklogTracer.getBacklogTracer(camelContext);
         if (tracer == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventHandler.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventHandler.java
 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventHandler.java
index 754b4d6..bcd45d8 100644
--- 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventHandler.java
+++ 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventHandler.java
@@ -33,6 +33,7 @@ import org.apache.camel.util.ServiceHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Deprecated
 public class DefaultTraceEventHandler implements TraceEventHandler, Service {
     private static final Logger LOG = 
LoggerFactory.getLogger(DefaultTraceEventHandler.class);
     

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
index 0376349..94569cb 100644
--- 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
+++ 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
@@ -108,8 +108,10 @@ public final class DefaultTraceEventMessage implements 
Serializable, TraceEventM
     private static String extractFromNode(Exchange exchange) {
         if (exchange.getUnitOfWork() != null) {
             TracedRouteNodes traced = 
exchange.getUnitOfWork().getTracedRouteNodes();
-            RouteNode last = traced.getSecondLastNode();
-            return last != null ? last.getLabel(exchange) : null;
+            if (traced != null) {
+                RouteNode last = traced.getSecondLastNode();
+                return last != null ? last.getLabel(exchange) : null;
+            }
         }
         return null;
     }
@@ -117,8 +119,10 @@ public final class DefaultTraceEventMessage implements 
Serializable, TraceEventM
     private static String extractToNode(Exchange exchange) {
         if (exchange.getUnitOfWork() != null) {
             TracedRouteNodes traced = 
exchange.getUnitOfWork().getTracedRouteNodes();
-            RouteNode last = traced.getLastNode();
-            return last != null ? last.getLabel(exchange) : null;
+            if (traced != null) {
+                RouteNode last = traced.getLastNode();
+                return last != null ? last.getLabel(exchange) : null;
+            }
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
index a02c3da..8c76a20 100644
--- 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
+++ 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
@@ -351,24 +351,25 @@ public class DefaultTraceFormatter implements 
TraceFormatter {
         if (showNode || showRouteId) {
             if (exchange.getUnitOfWork() != null) {
                 TracedRouteNodes traced = 
exchange.getUnitOfWork().getTracedRouteNodes();
-
-                RouteNode traceFrom = traced.getSecondLastNode();
-                if (traceFrom != null) {
-                    from = getNodeMessage(traceFrom, exchange);
-                } else if (exchange.getFromEndpoint() != null) {
-                    from = "from(" + 
exchange.getFromEndpoint().getEndpointUri() + ")";
-                }
-
-                RouteNode traceTo = traced.getLastNode();
-                if (traceTo != null) {
-                    to = getNodeMessage(traceTo, exchange);
-                    // if its an abstract dummy holder then we have to get the 
2nd last so we can get the real node that has
-                    // information which route it belongs to
-                    if (traceTo.isAbstract() && 
traceTo.getProcessorDefinition() == null) {
-                        traceTo = traced.getSecondLastNode();
+                if (traced != null) {
+                    RouteNode traceFrom = traced.getSecondLastNode();
+                    if (traceFrom != null) {
+                        from = getNodeMessage(traceFrom, exchange);
+                    } else if (exchange.getFromEndpoint() != null) {
+                        from = "from(" + 
exchange.getFromEndpoint().getEndpointUri() + ")";
                     }
+
+                    RouteNode traceTo = traced.getLastNode();
                     if (traceTo != null) {
-                        route = extractRoute(traceTo.getProcessorDefinition());
+                        to = getNodeMessage(traceTo, exchange);
+                        // if its an abstract dummy holder then we have to get 
the 2nd last so we can get the real node that has
+                        // information which route it belongs to
+                        if (traceTo.isAbstract() && 
traceTo.getProcessorDefinition() == null) {
+                            traceTo = traced.getSecondLastNode();
+                        }
+                        if (traceTo != null) {
+                            route = 
extractRoute(traceTo.getProcessorDefinition());
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
index a9fead2..8bad774 100644
--- 
a/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
+++ 
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
@@ -127,28 +127,29 @@ public class TraceInterceptor extends 
DelegateAsyncProcessor implements Exchange
                 // traced holds the information about the current traced route 
path
                 if (exchange.getUnitOfWork() != null) {
                     TracedRouteNodes traced = 
exchange.getUnitOfWork().getTracedRouteNodes();
-
-                    if (node instanceof OnCompletionDefinition || node 
instanceof OnExceptionDefinition) {
-                        // skip any of these as its just a marker definition
-                        trace = false;
-                    } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(OnCompletionDefinition.class, 
node)) {
-                        // special for on completion tracing
-                        traceOnCompletion(traced, exchange);
-                    } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(OnExceptionDefinition.class, 
node)) {
-                        // special for on exception
-                        traceOnException(traced, exchange);
-                    } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(CatchDefinition.class, node)) {
-                        // special for do catch
-                        traceDoCatch(traced, exchange);
-                    } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(FinallyDefinition.class, node)) {
-                        // special for do finally
-                        traceDoFinally(traced, exchange);
-                    } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(AggregateDefinition.class, node)) 
{
-                        // special for aggregate
-                        traceAggregate(traced, exchange);
-                    } else {
-                        // regular so just add it
-                        traced.addTraced(new DefaultRouteNode(node, 
super.getProcessor()));
+                    if (traced != null) {
+                        if (node instanceof OnCompletionDefinition || node 
instanceof OnExceptionDefinition) {
+                            // skip any of these as its just a marker 
definition
+                            trace = false;
+                        } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(OnCompletionDefinition.class, 
node)) {
+                            // special for on completion tracing
+                            traceOnCompletion(traced, exchange);
+                        } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(OnExceptionDefinition.class, 
node)) {
+                            // special for on exception
+                            traceOnException(traced, exchange);
+                        } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(CatchDefinition.class, node)) {
+                            // special for do catch
+                            traceDoCatch(traced, exchange);
+                        } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(FinallyDefinition.class, node)) {
+                            // special for do finally
+                            traceDoFinally(traced, exchange);
+                        } else if 
(ProcessorDefinitionHelper.isFirstChildOfType(AggregateDefinition.class, node)) 
{
+                            // special for aggregate
+                            traceAggregate(traced, exchange);
+                        } else {
+                            // regular so just add it
+                            traced.addTraced(new DefaultRouteNode(node, 
super.getProcessor()));
+                        }
                     }
                 } else {
                     LOG.trace("Cannot trace as this Exchange does not have an 
UnitOfWork: {}", exchange);
@@ -171,7 +172,9 @@ public class TraceInterceptor extends 
DelegateAsyncProcessor implements 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);
+                if (traced != null) {
+                    traceIntercept((InterceptDefinition) node.getParent(), 
traced, exchange);
+                }
             }
 
             // process the exchange

http://git-wip-us.apache.org/repos/asf/camel/blob/629b4c01/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
 
b/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
index d2601a7..4d03a4a 100644
--- 
a/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
@@ -26,10 +26,13 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.management.InstrumentationProcessor;
 import org.apache.camel.spi.TracedRouteNodes;
+import org.junit.Ignore;
 
 /**
  * @version 
  */
+@Deprecated
+@Ignore
 public class TraceableUnitOfWorkTest extends ContextTestSupport {
 
     public void testSendingSomeMessages() throws Exception {

Reply via email to