TraceInterceptor does not work correctly for AsyncProcessing
------------------------------------------------------------

                 Key: CAMEL-4246
                 URL: https://issues.apache.org/jira/browse/CAMEL-4246
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.7.1
            Reporter: Yaytay
            Priority: Minor


TraceEventHandlers are not called correctly when a node is processed 
asynchronously.

>From  org.apache.camel.processor.interceptor.TraceInterceptor:
            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);
                }

                // 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);
                }
            }

As it is this results in traceExchangeOut being called before the callback, 
which is wrong.
The call to super.process needs to wrap the callback to call traceExchangeOut 
(and the finally block shouldn't run if the process is asynch).

This isn't a regression, but the change to make more routes asynchronous makes 
it more noticeable.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to