This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit d80d4c2ae04c6defb3c3de5f9ff5ef12e461cb1a Author: Jess Sightler <[email protected]> AuthorDate: Fri Dec 7 13:07:43 2018 -0500 CAMEL-12985: TransactionErrorHandler fails if UnitOfWork is null --- .../java/org/apache/camel/spring/spi/TransactionErrorHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java index 5d3bf78..8177c4b 100644 --- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java +++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java @@ -95,7 +95,7 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler { public void process(Exchange exchange) throws Exception { // we have to run this synchronously as Spring Transaction does *not* support // using multiple threads to span a transaction - if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW && exchange.getUnitOfWork().isTransactedBy(transactionKey)) { + if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW && exchange.getUnitOfWork() != null && exchange.getUnitOfWork().isTransactedBy(transactionKey)) { // already transacted by this transaction template // so lets just let the error handler process it processByErrorHandler(exchange); @@ -129,7 +129,8 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler { try { // mark the beginning of this transaction boundary - exchange.getUnitOfWork().beginTransactedBy(transactionKey); + if (exchange.getUnitOfWork() != null) + exchange.getUnitOfWork().beginTransactedBy(transactionKey); // do in transaction logTransactionBegin(redelivered, ids); @@ -144,7 +145,8 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler { logTransactionRollback(redelivered, ids, e, false); } finally { // mark the end of this transaction boundary - exchange.getUnitOfWork().endTransactedBy(transactionKey); + if (exchange.getUnitOfWork() != null) + exchange.getUnitOfWork().endTransactedBy(transactionKey); } // if it was a local rollback only then remove its marker so outer transaction wont see the marker
