Repository: camel
Updated Branches:
  refs/heads/master bfb0a8f0f -> f5116063b


Fix erroneous logging when mapTemplate.size()==1

If mapTemplate.size()==1, the previous logic would still output the "Cannot 
determine which one to use" message.  Minor issue, but the structure of the 
internal if statements would leave room for silly logic errors if other code 
were inserted without thinking hard about all the logical combinations.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5116063
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5116063
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5116063

Branch: refs/heads/master
Commit: f5116063bcfac751ca89aea308cfa611687c2194
Parents: b46df1f
Author: cjnygard <cjnyg...@users.noreply.github.com>
Authored: Tue Jan 12 12:16:26 2016 -0500
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Jan 14 16:31:00 2016 +0000

----------------------------------------------------------------------
 .../spring/spi/TransactionErrorHandlerBuilder.java    | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f5116063/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
 
b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
index 27ab662..d3cad1b 100644
--- 
a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
+++ 
b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
@@ -76,12 +76,11 @@ public class TransactionErrorHandlerBuilder extends 
DefaultErrorHandlerBuilder {
 
             if (transactionTemplate == null) {
                 Map<String, TransactionTemplate> mapTemplate = 
routeContext.lookupByType(TransactionTemplate.class);
-                if (mapTemplate != null && mapTemplate.size() == 1) {
-                    transactionTemplate = 
mapTemplate.values().iterator().next();
-                }
                 if (mapTemplate == null || mapTemplate.isEmpty()) {
                     LOG.trace("No TransactionTemplate found in registry.");
-                } else {
+                } else if (mapTemplate.size() == 1) {
+                    transactionTemplate = 
mapTemplate.values().iterator().next();
+                }else {
                     LOG.debug("Found {} TransactionTemplate in registry. 
Cannot determine which one to use. "
                               + "Please configure a TransactionTemplate on the 
TransactionErrorHandlerBuilder", mapTemplate.size());
                 }
@@ -89,12 +88,11 @@ public class TransactionErrorHandlerBuilder extends 
DefaultErrorHandlerBuilder {
 
             if (transactionTemplate == null) {
                 Map<String, PlatformTransactionManager> mapManager = 
routeContext.lookupByType(PlatformTransactionManager.class);
-                if (mapManager != null && mapManager.size() == 1) {
-                    transactionTemplate = new 
TransactionTemplate(mapManager.values().iterator().next());
-                }
                 if (mapManager == null || mapManager.isEmpty()) {
                     LOG.trace("No PlatformTransactionManager found in 
registry.");
-                } else {
+                } else if (mapManager.size() == 1) {
+                    transactionTemplate = new 
TransactionTemplate(mapManager.values().iterator().next());
+                }else {
                     LOG.debug("Found {} PlatformTransactionManager in 
registry. Cannot determine which one to use for TransactionTemplate. "
                               + "Please configure a TransactionTemplate on the 
TransactionErrorHandlerBuilder", mapManager.size());
                 }

Reply via email to