This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 448a299fa003b9a09a1c87374f14fb6b854218b9 Author: Henning Garus <henning.ga...@gmail.com> AuthorDate: Fri Feb 17 19:31:01 2023 +0100 CAMEL-19066: Do not copy correlationId after multicast (#9367) Co-authored-by: Henning Garus <Âhenning.garusÂ@gmaiÃl.com> --- .../apache/camel/processor/MulticastProcessor.java | 2 + .../processor/MulticastCorrelationIdTest.java | 49 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java index af740f9b1c2..8ea0a05858a 100644 --- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java +++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java @@ -801,7 +801,9 @@ public class MulticastProcessor extends AsyncProcessorSupport original.setException(subExchange.getException()); } else { // copy the current result to original, so it will contain this result of this eip + Object correlationId = subExchange.removeProperty(ExchangePropertyKey.CORRELATION_ID); ExchangeHelper.copyResults(original, subExchange); + subExchange.setProperty(ExchangePropertyKey.CORRELATION_ID, correlationId); } } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/MulticastCorrelationIdTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/MulticastCorrelationIdTest.java new file mode 100644 index 00000000000..4c285b51d35 --- /dev/null +++ b/core/camel-core/src/test/java/org/apache/camel/processor/MulticastCorrelationIdTest.java @@ -0,0 +1,49 @@ +/* + * 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.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MulticastCorrelationIdTest extends ContextTestSupport { + + @Test + void testCorrelationIdIsNotOverwrittenByMulticast() { + String originalCorrelationId = "SOME_ID"; + Exchange exchange + = template.request("direct:start", e -> e.setProperty(Exchange.CORRELATION_ID, originalCorrelationId)); + + assertEquals(originalCorrelationId, exchange.getProperty(Exchange.CORRELATION_ID)); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").multicast().to("direct:a", "direct:b"); + from("direct:a").log("Route a"); + from("direct:b").log("Route b"); + } + }; + } + +}