This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 67cf609766e8978718e5985e912a0507f9bb0492 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Wed Nov 23 09:28:49 2022 +0100 CAMEL-15105: rework usages of ExtendedExchange in ExchangeHelper --- .../org/apache/camel/support/ExchangeHelper.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java index 4dda266f475..06c5ecde07c 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java @@ -37,7 +37,6 @@ import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.ExchangePropertyKey; -import org.apache.camel.ExtendedExchange; import org.apache.camel.Message; import org.apache.camel.MessageHistory; import org.apache.camel.NoSuchBeanException; @@ -292,11 +291,10 @@ public final class ExchangeHelper { copy.getIn().setMessageId(null); } // do not share the unit of work - ExtendedExchange ce = (ExtendedExchange) copy; - ce.setUnitOfWork(null); + copy.getExchangeExtension().setUnitOfWork(null); if (handover) { // Need to hand over the completion for async invocation - exchange.adapt(ExtendedExchange.class).handoverCompletions(ce); + exchange.getExchangeExtension().handoverCompletions(copy); } // set a correlation id so we can track back the original exchange copy.setProperty(ExchangePropertyKey.CORRELATION_ID, id); @@ -329,7 +327,7 @@ public final class ExchangeHelper { * @param source the source exchange which is not modified */ public static void copyResults(Exchange target, Exchange source) { - doCopyResults((ExtendedExchange) target, (ExtendedExchange) source, false); + doCopyResults(target, source, false); } /** @@ -340,10 +338,10 @@ public final class ExchangeHelper { * @param source source exchange. */ public static void copyResultsPreservePattern(Exchange target, Exchange source) { - doCopyResults((ExtendedExchange) target, (ExtendedExchange) source, true); + doCopyResults(target, source, true); } - private static void doCopyResults(ExtendedExchange result, ExtendedExchange source, boolean preserverPattern) { + private static void doCopyResults(Exchange result, Exchange source, boolean preserverPattern) { if (result == source) { // we just need to ensure MEP is as expected (eg copy result to OUT if out capable) // and the result is not failed @@ -389,15 +387,15 @@ public final class ExchangeHelper { if (source.hasProperties()) { result.getProperties().putAll(source.getProperties()); } - source.adapt(ExtendedExchange.class).copyInternalProperties(result); + source.getExchangeExtension().copyInternalProperties(result); // copy over state result.setRouteStop(source.isRouteStop()); result.setRollbackOnly(source.isRollbackOnly()); result.setRollbackOnlyLast(source.isRollbackOnlyLast()); - result.setNotifyEvent(source.isNotifyEvent()); - result.setRedeliveryExhausted(source.isRedeliveryExhausted()); - result.setErrorHandlerHandled(source.getErrorHandlerHandled()); + result.getExchangeExtension().setNotifyEvent(source.getExchangeExtension().isNotifyEvent()); + result.getExchangeExtension().setRedeliveryExhausted(source.getExchangeExtension().isRedeliveryExhausted()); + result.getExchangeExtension().setErrorHandlerHandled(source.getExchangeExtension().getErrorHandlerHandled()); result.setException(source.getException()); } @@ -814,9 +812,9 @@ public final class ExchangeHelper { public static Exchange copyExchangeAndSetCamelContext(Exchange exchange, CamelContext context, boolean handover) { DefaultExchange answer = new DefaultExchange(context, exchange.getPattern()); if (exchange.hasProperties()) { - answer.setProperties(safeCopyProperties(exchange.getProperties())); + answer.getExchangeExtension().setProperties(safeCopyProperties(exchange.getProperties())); } - exchange.adapt(ExtendedExchange.class).copyInternalProperties(answer); + exchange.getExchangeExtension().copyInternalProperties(answer); // safe copy message history using a defensive copy List<MessageHistory> history = (List<MessageHistory>) exchange.getProperty(ExchangePropertyKey.MESSAGE_HISTORY); @@ -827,7 +825,7 @@ public final class ExchangeHelper { if (handover) { // Need to hand over the completion for async invocation - exchange.adapt(ExtendedExchange.class).handoverCompletions(answer); + exchange.getExchangeExtension().handoverCompletions(answer); } answer.setIn(exchange.getIn().copy()); if (exchange.hasOut()) {