Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

camel 2.10

  • Loading branch information...
commit 4179294f794236a797bbfc92e8d0c3ec7a1b1d65 1 parent 14f4dfd
@szhem authored
View
14 component/src/main/java/org/apache/camel/osgi/service/OsgiDefaultConsumer.java
@@ -18,7 +18,6 @@
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.SuspendableService;
-import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.support.ServiceSupport;
import org.apache.camel.util.ExchangeHelper;
import org.apache.camel.util.ServiceHelper;
@@ -27,7 +26,6 @@
import java.util.Hashtable;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
/**
* The {@code OsgiDefaultConsumer} is the default consumer for the camel OSGi component.
@@ -120,18 +118,8 @@ public void process(final Exchange exchange) throws Exception {
protected Exchange copyExchange(Exchange exchange) {
OsgiDefaultEndpoint endpoint = getEndpoint();
- DefaultExchange copy = new DefaultExchange(endpoint.getCamelContext(), exchange.getPattern());
+ Exchange copy = ExchangeHelper.copyExchangeAndSetCamelContext(exchange, endpoint.getCamelContext(), false);
copy.setFromEndpoint(endpoint);
- copy.setProperty(Exchange.CORRELATION_ID, exchange.getExchangeId());
-
- if (exchange.hasProperties()) {
- copy.setProperties(new ConcurrentHashMap<String, Object>(exchange.getProperties()));
- }
- copy.getIn().copyFrom(exchange.getIn());
- if (exchange.hasOut()) {
- copy.getOut().copyFrom(exchange.getOut());
- }
- copy.setException(exchange.getException());
return copy;
}
View
3  component/src/test/java/org/apache/camel/osgi/service/OsgiDefaultConsumerTest.java
@@ -213,17 +213,14 @@ public void testCopyExchange() throws Exception {
Exchange exchange = mock(Exchange.class, RETURNS_MOCKS);
when(exchange.getPattern()).thenReturn(ExchangePattern.OutOptionalIn);
- when(exchange.getExchangeId()).thenReturn("12345");
Exchange copy = consumer.copyExchange(exchange);
verify(exchange, atLeastOnce()).getPattern();
- verify(exchange, atLeastOnce()).getExchangeId();
verify(exchange, atLeastOnce()).getIn();
verify(exchange, atLeastOnce()).getException();
assertThat(copy.getPattern(), sameInstance(ExchangePattern.OutOptionalIn));
- assertThat(copy.getProperty(Exchange.CORRELATION_ID, String.class), equalTo("12345"));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.