You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/03/25 10:03:30 UTC

[camel] branch camel-3.1.x updated (f675c4d -> 5776b79)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-3.1.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from f675c4d  Updating Shiro to 1.5.2 due to CVE-2020-1957
     new 48b9965  CAMEL-14739: Added unit test to reproduce bug. Thanks to Nathan for reporting.
     new 5776b79  CAMEL-14739: Fix core optimization would lose route detail on UoW when nesting down many routes.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/impl/engine/DefaultUnitOfWork.java       | 16 ++---
 ...tionErrorHandlerNoRouteOnExchangeIssueTest.java | 77 ++++++++++++++++++++++
 2 files changed, 83 insertions(+), 10 deletions(-)
 create mode 100644 core/camel-core/src/test/java/org/apache/camel/issues/OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java


[camel] 01/02: CAMEL-14739: Added unit test to reproduce bug. Thanks to Nathan for reporting.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.1.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 48b9965c1b2317bd3337a7a5011bfa1c87edc2d3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 25 10:11:50 2020 +0100

    CAMEL-14739: Added unit test to reproduce bug. Thanks to Nathan for reporting.
---
 ...tionErrorHandlerNoRouteOnExchangeIssueTest.java | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)

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
new file mode 100644
index 0000000..d91492e
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/issues/OnExceptionErrorHandlerNoRouteOnExchangeIssueTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.issues;
+
+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 {
+
+    @Test
+    public void testOk() throws Exception {
+        String out = template.requestBody("direct:hello", null, String.class);
+        assertEquals("Hello World", out);
+    }
+
+    @Test
+    public void testNormalError() throws Exception {
+        String out = template.requestBody("direct:normalError", null, String.class);
+        assertEquals("general exception was properly handled", out);
+    }
+
+    @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);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class)
+                        .handled(true)
+                        .log(LoggingLevel.ERROR, "error", "${messageHistory} \n ${exchange} \n ${exception.stacktrace}")
+                        .transform().simple("general exception was properly handled")
+                        .stop();
+
+                from("direct:hello").routeId("routeHello")
+                        .transform().constant("Hello World")
+                        .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200));
+
+                from("direct:normalError").routeId("normalError")
+                        .throwException(new NullPointerException("some null value"))
+                        .to("direct:hello");
+
+                from("direct:bug").routeId("routeBug")
+                        .to("direct:detour")
+                        .throwException(new NullPointerException("something went wrong"))
+                        .to("direct:hello");
+
+                from("direct:detour").routeId("routeDetour1")
+                        .to("direct:detour2");
+
+                from("direct:detour2").routeId("routeDetour2")
+                        .transform().constant("random processing (should not be exposed)");
+            }
+        };
+    }
+}


[camel] 02/02: CAMEL-14739: Fix core optimization would lose route detail on UoW when nesting down many routes.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.1.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5776b7992627804b07aa1d50066b861327c1cccd
Author: Claus Ibsen <cl...@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  | 16 ++++++----------
 ...nExceptionErrorHandlerNoRouteOnExchangeIssueTest.java |  2 --
 2 files changed, 6 insertions(+), 12 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 2b5167e..34a40e3 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;
@@ -24,7 +26,6 @@ import java.util.Set;
 import java.util.function.Predicate;
 
 import org.apache.camel.AsyncCallback;
-import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.ExtendedExchange;
@@ -56,14 +57,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<RouteContext> 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 RouteContext prevRouteContext;
-    private RouteContext routeContext;
     private List<Synchronization> synchronizations;
     private Message originalInMessage;
     private Set<Object> transactedBy;
@@ -288,21 +288,17 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
 
     @Override
     public RouteContext getRouteContext() {
-        return routeContext;
+        return routes.peek();
     }
 
     @Override
     public void pushRouteContext(RouteContext routeContext) {
-        this.prevRouteContext = this.routeContext;
-        this.routeContext = routeContext;
+        routes.push(routeContext);
     }
 
     @Override
     public RouteContext popRouteContext() {
-        RouteContext answer = this.routeContext;
-        this.routeContext = this.prevRouteContext;
-        this.prevRouteContext = null;
-        return answer;
+        return routes.poll();
     }
 
     @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);