camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7630 Fixed the BlueprintPropertiesParser paser issue with multiple PropertyPlaceholders.
Date Thu, 24 Jul 2014 00:44:59 GMT
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/07841d5b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/07841d5b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/07841d5b

Branch: refs/heads/master
Commit: 07841d5be1175be1e9f383497588ff4e29e3008e
Parents: 9f88bcb
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Jul 24 08:42:10 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Jul 24 08:44:20 2014 +0800

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


http://git-wip-us.apache.org/repos/asf/camel/blob/07841d5b/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;


Mime
View raw message