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 425ff84 CAMEL-16276: Fixed using noErrorHandler does not start child
outputs. Thanks to Simo Kivimaki for reporting and the unit test.
425ff84 is described below
commit 425ff8465e028ae253ce7cdbf1beb9fb7670f490
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Mar 2 09:35:05 2021 +0100
CAMEL-16276: Fixed using noErrorHandler does not start child outputs.
Thanks to Simo Kivimaki for reporting and the unit test.
---
.../processor/errorhandler/NoErrorHandler.java | 24 ++++++++++
.../camel/processor/WireTapNoErrorHandlerTest.java | 54 ++++++++++++++++++++++
2 files changed, 78 insertions(+)
diff --git
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/NoErrorHandler.java
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/NoErrorHandler.java
index 22f4e9f..57c85ed 100644
---
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/NoErrorHandler.java
+++
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/NoErrorHandler.java
@@ -27,6 +27,7 @@ import org.apache.camel.spi.ErrorHandler;
import org.apache.camel.support.AsyncCallbackToCompletableFutureAdapter;
import org.apache.camel.support.AsyncProcessorConverterHelper;
import org.apache.camel.support.AsyncProcessorHelper;
+import org.apache.camel.support.service.ServiceHelper;
public class NoErrorHandler extends ErrorHandlerSupport implements
AsyncProcessor, ErrorHandler {
@@ -82,4 +83,27 @@ public class NoErrorHandler extends ErrorHandlerSupport
implements AsyncProcesso
public ErrorHandler clone(Processor output) {
return new NoErrorHandler(output);
}
+
+ @Override
+ protected void doInit() throws Exception {
+ ServiceHelper.initService(output);
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ ServiceHelper.startService(output);
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ // noop, do not stop any services which we only do when shutting down
+ // as the error handler can be context scoped, and should not stop in
case
+ // a route stops
+ }
+
+ @Override
+ protected void doShutdown() throws Exception {
+ ServiceHelper.stopAndShutdownServices(output);
+ }
+
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/WireTapNoErrorHandlerTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/WireTapNoErrorHandlerTest.java
new file mode 100644
index 0000000..ab18693
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/WireTapNoErrorHandlerTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+public class WireTapNoErrorHandlerTest extends ContextTestSupport {
+
+ @Test
+ public void testWireTap() throws Exception {
+ MockEndpoint tap = getMockEndpoint("mock:tap");
+ MockEndpoint result = getMockEndpoint("mock:result");
+ // hello must come first, as we have delay on the tapped route
+ result.expectedBodiesReceived("Hello World", "Tapped");
+ tap.expectedBodiesReceived("Tapped");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .errorHandler(noErrorHandler())
+ .to("log:foo").wireTap("direct:tap").to("mock:result");
+
+ from("direct:tap")
+ .delay(1000)
+ .setBody().constant("Tapped")
+ .to("mock:result", "mock:tap");
+ }
+ };
+ }
+}