Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x ba18a3fef -> f9b44bc6f
  refs/heads/master ad77114ad -> 3bd749165


CAMEL-8115: Properties component - Include default functions to lookup from ENV 
/ SYS etc


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

Branch: refs/heads/master
Commit: 3bd749165c91b6973618a750df597a2ab5e39266
Parents: ad77114
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Dec 9 13:18:25 2014 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Dec 9 14:47:59 2014 +0100

----------------------------------------------------------------------
 .../component/properties/DefaultPropertiesParser.java | 14 +++++++++++++-
 .../properties/PropertiesComponentFunctionTest.java   |  1 +
 .../SpringPropertiesComponentFunctionTest.xml         |  1 +
 .../blueprint/PropertiesComponentFunctionTest.xml     |  1 +
 4 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3bd74916/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
 
b/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
index e8333b7..fdd2896 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/properties/DefaultPropertiesParser.java
@@ -105,6 +105,9 @@ public class DefaultPropertiesParser implements 
AugmentedPropertyNameAwareProper
          * @return Evaluated string
          */
         private String doParse(String input, Set<String> replacedPropertyKeys) 
{
+            if (input == null) {
+                return null;
+            }
             String answer = input;
             Property property;
             while ((property = readProperty(answer)) != null) {
@@ -216,7 +219,16 @@ public class DefaultPropertiesParser implements 
AugmentedPropertyNameAwareProper
                     if (key.startsWith(token)) {
                         String remainder = key.substring(token.length());
                         log.debug("Property with key [{}] is applied by 
function [{}]", key, function.getName());
-                        return function.apply(remainder);
+                        String value = function.apply(remainder);
+                        if (value == null) {
+                            throw new IllegalArgumentException("Property with 
key [" + key + "] using function [" + function.getName() + "]" +
+                                    " returned null value which is not 
allowed, from input: " + input);
+                        } else {
+                            if (log.isDebugEnabled()) {
+                                log.debug("Property with key [{}] applied by 
function [{}] -> {}", new Object[]{key, function.getName(), value});
+                            }
+                            return value;
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/3bd74916/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentFunctionTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentFunctionTest.java
 
b/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentFunctionTest.java
index f960f6d..21dcb56 100644
--- 
a/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentFunctionTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentFunctionTest.java
@@ -47,6 +47,7 @@ public class PropertiesComponentFunctionTest extends 
ContextTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
+                        .to("log:{{sys:os.name}}")
                         .to("{{beer:FOO}}")
                         .to("{{beer:BAR}}");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/3bd74916/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentFunctionTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentFunctionTest.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentFunctionTest.xml
index 8d6e865..9da34bd 100644
--- 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentFunctionTest.xml
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentFunctionTest.xml
@@ -32,6 +32,7 @@
 
     <route>
       <from uri="direct:start"/>
+      <to uri="log:{{sys:os.name}}"/>
       <to uri="{{beer:FOO}}"/>
       <to uri="{{beer:BAR}}"/>
     </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/3bd74916/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml
 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml
index d2cba08..7e06784 100644
--- 
a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml
+++ 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml
@@ -32,6 +32,7 @@
 
     <route>
       <from uri="direct:start"/>
+      <to uri="log:{{sys:os.name}}"/>
       <to uri="{{beer:FOO}}"/>
       <to uri="{{beer:BAR}}"/>
     </route>

Reply via email to