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 4ac562b  CAMEL-14739: Fix core optimization would lose route detail on 
UoW when nesting down many routes.
4ac562b is described below

commit 4ac562b784d0cdc4aff1a8d7046660db9e9461da
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Mar 25 10:55:47 2020 +0100

    CAMEL-14739: Fix core optimization would lose route detail on UoW when 
nesting down many routes.
---
 .../org/apache/camel/impl/engine/DefaultUnitOfWork.java   | 15 ++++++---------
 ...OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java |  2 --
 2 files changed, 6 insertions(+), 11 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 e404de5..d7969de 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
@@ -16,7 +16,9 @@
  */
 package org.apache.camel.impl.engine;
 
+import java.util.ArrayDeque;
 import java.util.ArrayList;
+import java.util.Deque;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -54,14 +56,13 @@ public class DefaultUnitOfWork implements UnitOfWork, 
Service {
     //   introduce a simpler UnitOfWork concept. This would also allow us to 
refactor the
     //   SubUnitOfWork into a general parent/child unit of work concept. 
However this
     //   requires API changes and thus is best kept for future Camel work
+    private final Deque<Route> routes = new ArrayDeque<>(8);
     final InflightRepository inflightRepository;
     final boolean allowUseOriginalMessage;
     final boolean useBreadcrumb;
     private final Exchange exchange;
     private final ExtendedCamelContext context;
     private Logger log;
-    private Route prevRoute;
-    private Route route;
     private List<Synchronization> synchronizations;
     private Message originalInMessage;
     private Set<Object> transactedBy;
@@ -286,21 +287,17 @@ public class DefaultUnitOfWork implements UnitOfWork, 
Service {
 
     @Override
     public Route getRoute() {
-        return route;
+        return routes.peek();
     }
 
     @Override
     public void pushRoute(Route route) {
-        this.prevRoute = this.route;
-        this.route = route;
+        routes.push(route);
     }
 
     @Override
     public Route popRoute() {
-        Route answer = this.route;
-        this.route = this.prevRoute;
-        this.prevRoute = null;
-        return answer;
+        return routes.pop();
     }
 
     @Override
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/issues/OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/issues/OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java
index d91492e..108e181 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/issues/OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/issues/OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java
@@ -20,7 +20,6 @@ import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class OnExceptionErrorHandlerNoRouteOnExchangeIssueTest  extends 
ContextTestSupport {
@@ -38,7 +37,6 @@ public class 
OnExceptionErrorHandlerNoRouteOnExchangeIssueTest  extends ContextT
     }
 
     @Test
-    @Ignore("TODO: Fix me https://issues.apache.org/jira/browse/CAMEL-14739";)
     public void testBug() throws Exception {
         String out = template.requestBody("direct:bug", null, String.class);
         assertEquals("general exception was properly handled", out);

Reply via email to