This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 8c62825 CAMEL-14354: Optimize core 8c62825 is described below commit 8c6282555956e0ffbd83289ecec2c36a12e0c79b Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Jan 19 12:02:18 2020 +0100 CAMEL-14354: Optimize core --- .../java/org/apache/camel/processor/Pipeline.java | 22 ++++++++++++++-------- .../org/apache/camel/processor/PipelineHelper.java | 4 +++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java b/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java index 8e2f5f3..6b94f5f 100644 --- a/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java +++ b/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java @@ -82,16 +82,16 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo @Override public boolean process(Exchange exchange, AsyncCallback callback) { if (exchange.isTransacted()) { - camelContext.getReactiveExecutor().scheduleSync(() -> Pipeline.this.doProcess(exchange, callback, processors, 0, true)); + camelContext.getReactiveExecutor().scheduleSync(() -> Pipeline.this.doProcess(exchange, callback, processors, 0)); } else { - camelContext.getReactiveExecutor().scheduleMain(() -> Pipeline.this.doProcess(exchange, callback, processors, 0, true)); + camelContext.getReactiveExecutor().scheduleMain(() -> Pipeline.this.doProcess(exchange, callback, processors, 0)); } return false; } - protected void doProcess(Exchange exchange, AsyncCallback callback, List<AsyncProcessor> processors, int index, boolean first) { + protected void doProcess(Exchange exchange, AsyncCallback callback, List<AsyncProcessor> processors, int index) { if (continueRouting(processors, index, exchange) - && (first || continueProcessing(exchange, "so breaking out of pipeline", log))) { + && (index == 0 || continueProcessing(exchange, "so breaking out of pipeline", log))) { // prepare for next run ExchangeHelper.prepareOutToIn(exchange); @@ -101,14 +101,16 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo final Integer idx = index + 1; processor.process(exchange, doneSync -> - camelContext.getReactiveExecutor().schedule(() -> doProcess(exchange, callback, processors, idx, false))); + camelContext.getReactiveExecutor().schedule(() -> doProcess(exchange, callback, processors, idx))); } else { ExchangeHelper.copyResults(exchange, exchange); // logging nextExchange as it contains the exchange that might have altered the payload and since // we are logging the completion if will be confusing if we log the original instead // we could also consider logging the original and the nextExchange then we have *before* and *after* snapshots - log.trace("Processing complete for exchangeId: {} >>> {}", exchange.getExchangeId(), exchange); + if (log.isTraceEnabled()) { + log.trace("Processing complete for exchangeId: {} >>> {}", exchange.getExchangeId(), exchange); + } camelContext.getReactiveExecutor().schedule(callback); } @@ -119,13 +121,17 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo if (stop != null) { boolean doStop = exchange.getContext().getTypeConverter().convertTo(Boolean.class, stop); if (doStop) { - log.debug("ExchangeId: {} is marked to stop routing: {}", exchange.getExchangeId(), exchange); + if (log.isTraceEnabled()) { + log.debug("ExchangeId: {} is marked to stop routing: {}", exchange.getExchangeId(), exchange); + } return false; } } // continue if there are more processors to route boolean answer = index < processors.size(); - log.trace("ExchangeId: {} should continue routing: {}", exchange.getExchangeId(), answer); + if (log.isTraceEnabled()) { + log.trace("ExchangeId: {} should continue routing: {}", exchange.getExchangeId(), answer); + } return answer; } diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/PipelineHelper.java b/core/camel-base/src/main/java/org/apache/camel/processor/PipelineHelper.java index b80e590..d29deba 100644 --- a/core/camel-base/src/main/java/org/apache/camel/processor/PipelineHelper.java +++ b/core/camel-base/src/main/java/org/apache/camel/processor/PipelineHelper.java @@ -67,7 +67,9 @@ public final class PipelineHelper { if (stop != null) { boolean doStop = exchange.getContext().getTypeConverter().convertTo(Boolean.class, exchange, stop); if (doStop) { - log.debug("ExchangeId: {} is marked to stop routing: {}", exchange.getExchangeId(), exchange); + if (log.isDebugEnabled()) { + log.debug("ExchangeId: {} is marked to stop routing: {}", exchange.getExchangeId(), exchange); + } return false; } }