Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x db1711054 -> b25b375fc
  refs/heads/camel-2.13.x c23789af5 -> 3b17bd3c9


CAMEL-7630 Fixed the BlueprintPropertiesParser paser issue with multiple 
PropertyPlaceholders.


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

Branch: refs/heads/camel-2.13.x
Commit: 36e35bf3ca87d482775851beec7a38e97d1fc92d
Parents: c23789a
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu Jul 24 08:42:10 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu Jul 24 08:46:27 2014 +0800

----------------------------------------------------------------------
 .../blueprint/BlueprintPropertiesParser.java    | 29 ++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/36e35bf3/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
----------------------------------------------------------------------
diff --git 
a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
 
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
index 4069c5f..d1bbde6 100644
--- 
a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
+++ 
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
@@ -122,7 +122,6 @@ public class BlueprintPropertiesParser extends 
DefaultPropertiesParser {
         // lookup key in blueprint and return its value
         if (answer == null && key != null) {
             for (AbstractPropertyPlaceholder placeholder : placeholders) {
-
                 boolean isDefault = false;
                 if (placeholders.size() > 1) {
                     // okay we have multiple placeholders and we want to 
return the answer that
@@ -133,28 +132,36 @@ public class BlueprintPropertiesParser extends 
DefaultPropertiesParser {
                     }
                     log.trace("Blueprint property key: {} is part of default 
properties: {}", key, isDefault);
                 }
-
-                String candidate = (String) ObjectHelper.invokeMethod(method, 
placeholder, key);
-
-                if (candidate != null) {
-                    if (answer == null || !isDefault) {
-                        log.trace("Blueprint parsed candidate property key: {} 
as value: {}", key, answer);
-                        answer = candidate;
+                
+                try {
+                    String candidate = (String) 
ObjectHelper.invokeMethod(method, placeholder, key);
+    
+                    if (candidate != null) {
+                        if (answer == null || !isDefault) {
+                            log.trace("Blueprint parsed candidate property 
key: {} as value: {}", key, answer);
+                            answer = candidate;
+                        }
                     }
-                }
+                } catch (Exception ex) {
+                    // Here we just catch the exception and try to use other 
candidate
+                }  
             }
-
             log.debug("Blueprint parsed property key: {} as value: {}", key, 
answer);
         }
-
+        
         // if there is a delegate then let it parse the current answer as it 
may be jasypt which
         // need to decrypt values
         if (delegate != null) {
             String delegateAnswer = delegate.parseProperty(key, answer != null 
? answer : value, properties);
             if (delegateAnswer != null) {
                 answer = delegateAnswer;
+                log.debug("delegate property parser parsed the property key:{} 
as value: {}", key, answer);
             }
         }
+        
+        if (answer == null) {
+            throw new IllegalArgumentException("Cannot parser the property 
key: " + key + " with value: " + value);
+        }
 
         log.trace("Returning parsed property key: {} as value: {}", key, 
answer);
         return answer;

Reply via email to