This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch sandbox/camel-3.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit e21f27987b6ce7ec7ebf23a132a8c3973b5e8c0f 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 6360368..4f493b5 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) { // 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
