[camel] branch master updated: CAMEL-14354: camel-core - Optimize

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-14354: camel-core - Optimize

davsclaus-2
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 a0462f0  CAMEL-14354: camel-core - Optimize
a0462f0 is described below

commit a0462f0caea149e14cf061df6e9183f1fefaab47
Author: Claus Ibsen <[hidden email]>
AuthorDate: Mon Jan 13 21:41:55 2020 +0100

    CAMEL-14354: camel-core - Optimize
---
 .../java/org/apache/camel/impl/engine/DefaultUnitOfWork.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
index 04e41f2..abcdc4a 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
@@ -58,7 +58,7 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
     //   requires API changes and thus is best kept for Camel 3.0
 
     private String id;
-    private CamelContext context;
+    private final CamelContext context;
     private List<Synchronization> synchronizations;
     private Message originalInMessage;
     private Set<Object> transactedBy;
@@ -98,7 +98,7 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
         }
 
         // inject breadcrumb header if enabled
-        if (exchange.getContext().isUseBreadcrumb()) {
+        if (context.isUseBreadcrumb()) {
             // create or use existing breadcrumb
             String breadcrumbId = exchange.getIn().getHeader(Exchange.BREADCRUMB_ID, String.class);
             if (breadcrumbId == null) {
@@ -121,16 +121,14 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
 
         // fire event
         try {
-            EventHelper.notifyExchangeCreated(exchange.getContext(), exchange);
+            EventHelper.notifyExchangeCreated(context, exchange);
         } catch (Throwable e) {
             // must catch exceptions to ensure the exchange is not failing due to notification event failed
             log.warn("Exception occurred during event notification. This exception will be ignored.", e);
         }
 
         // register to inflight registry
-        if (exchange.getContext() != null) {
-            exchange.getContext().getInflightRepository().add(exchange);
-        }
+        context.getInflightRepository().add(exchange);
     }
 
     UnitOfWork newInstance(Exchange exchange) {
@@ -287,7 +285,7 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
 
     @Override
     public boolean isTransactedBy(Object key) {
-        return getTransactedBy().contains(key);
+        return transactedBy != null && getTransactedBy().contains(key);
     }
 
     @Override