Small optimization on exchange to avoid looking up unnessasary type conversion and setting a null value on the property
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b16a262a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b16a262a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b16a262a Branch: refs/heads/master Commit: b16a262a92dfbcab8a3b346fb93be1791b3665bc Parents: 88ca1fb Author: Claus Ibsen <davscl...@apache.org> Authored: Fri May 26 18:05:18 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sat May 27 09:03:47 2017 +0200 ---------------------------------------------------------------------- .../java/org/apache/camel/impl/DefaultExchange.java | 12 +++++++----- .../java/org/apache/camel/impl/DefaultUnitOfWork.java | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b16a262a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java index 97b10a2..f43396a 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java @@ -426,11 +426,13 @@ public final class DefaultExchange implements Exchange { // lets avoid adding methods to the Message API, so we use the // DefaultMessage to allow component specific messages to extend // and implement the isExternalRedelivered method. - DefaultMessage msg = getIn(DefaultMessage.class); - if (msg != null) { - answer = msg.isTransactedRedelivered(); - // store as property to keep around - setProperty(Exchange.EXTERNAL_REDELIVERED, answer); + Message msg = getIn(); + if (msg instanceof DefaultMessage) { + answer = ((DefaultMessage) msg).isTransactedRedelivered(); + if (answer != null) { + // store as property to keep around + setProperty(Exchange.EXTERNAL_REDELIVERED, answer); + } } } http://git-wip-us.apache.org/repos/asf/camel/blob/b16a262a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java index 607afff..cb7e2a8 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java @@ -115,7 +115,10 @@ public class DefaultUnitOfWork implements UnitOfWork, Service { // setup whether the exchange is externally redelivered or not (if not initialized before) // store as property so we know that the origin exchange was redelivered if (exchange.getProperty(Exchange.EXTERNAL_REDELIVERED) == null) { - exchange.setProperty(Exchange.EXTERNAL_REDELIVERED, exchange.isExternalRedelivered()); + Boolean redelivered = exchange.isExternalRedelivered(); + if (redelivered != null) { + exchange.setProperty(Exchange.EXTERNAL_REDELIVERED, redelivered); + } } // fire event