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

commit 2a74c86ed69964ccf00a0e245d7aedd5fd560482
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sun Feb 2 19:01:23 2020 +0100

    CAMEL-14354: camel-core - Optimize to reduce calling method in critical path
---
 .../camel/processor/CamelInternalProcessor.java    | 39 ++++++++--------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git 
a/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
 
b/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
index 6b8265e..d447036 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
@@ -210,12 +210,25 @@ public class CamelInternalProcessor extends 
DelegateAsyncProcessor {
         // you can see in the code below.
         // ----------------------------------------------------------
 
-        if (processor == null || !continueProcessing(exchange)) {
+        if (processor == null || exchange.isRouteStop()) {
             // no processor or we should not continue then we are done
             originalCallback.done(true);
             return true;
         }
 
+        boolean forceShutdown = shutdownStrategy.forceShutdown(this);
+        if (forceShutdown) {
+            String msg = "Run not allowed as ShutdownStrategy is forcing 
shutting down, will reject executing exchange: " + exchange;
+            LOG.debug(msg);
+            if (exchange.getException() == null) {
+                exchange.setException(new RejectedExecutionException(msg));
+            }
+            // force shutdown so we should not continue
+            originalCallback.done(true);
+            return true;
+
+        }
+
         // optimise to use object array for states, and only for the number of 
advices that keep state
         final Object[] states = statefulAdvices > 0 ? new 
Object[statefulAdvices] : EMPTY_STATES;
         // optimise for loop using index access to avoid creating iterator 
object
@@ -299,30 +312,6 @@ public class CamelInternalProcessor extends 
DelegateAsyncProcessor {
     }
 
     /**
-     * Strategy to determine if we should continue processing the {@link 
Exchange}.
-     */
-    private boolean continueProcessing(Exchange exchange) {
-        if (exchange.isRouteStop()) {
-            LOG.debug("Exchange is marked to stop routing: {}", exchange);
-            return false;
-        }
-
-        // determine if we can still run, or the camel context is forcing a 
shutdown
-        boolean forceShutdown = shutdownStrategy.forceShutdown(this);
-        if (forceShutdown) {
-            String msg = "Run not allowed as ShutdownStrategy is forcing 
shutting down, will reject executing exchange: " + exchange;
-            LOG.debug(msg);
-            if (exchange.getException() == null) {
-                exchange.setException(new RejectedExecutionException(msg));
-            }
-            return false;
-        }
-
-        // yes we can continue
-        return true;
-    }
-
-    /**
      * Advice to invoke callbacks for before and after routing.
      */
     public static class RouteLifecycleAdvice implements 
CamelInternalProcessorAdvice<Object> {

Reply via email to