You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/06/08 16:54:14 UTC

[2/2] camel git commit: CAMEL-8845: Property placeholder - service lookup should use underscore instead of dash

CAMEL-8845: Property placeholder - service lookup should use underscore instead of dash


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

Branch: refs/heads/camel-2.15.x
Commit: 57da1472e3d78d0abe424e730719f9400161be66
Parents: f73bf52
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jun 8 16:58:46 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jun 8 16:59:23 2015 +0200

----------------------------------------------------------------------
 .../properties/ServicePropertiesFunction.java   | 21 ++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/57da1472/camel-core/src/main/java/org/apache/camel/component/properties/ServicePropertiesFunction.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/properties/ServicePropertiesFunction.java b/camel-core/src/main/java/org/apache/camel/component/properties/ServicePropertiesFunction.java
index c9c49f7..5ba4395 100644
--- a/camel-core/src/main/java/org/apache/camel/component/properties/ServicePropertiesFunction.java
+++ b/camel-core/src/main/java/org/apache/camel/component/properties/ServicePropertiesFunction.java
@@ -52,17 +52,22 @@ public class ServicePropertiesFunction implements PropertiesFunction {
         }
 
         // make sure to use upper case
-        key = key.toUpperCase(Locale.ENGLISH);
+        if (key != null) {
+            // make sure to use underscore as dash is not supported as ENV variables
+            key = key.toUpperCase(Locale.ENGLISH).replace('-', '_');
 
-        // a service should have both the host and port defined
-        String host = System.getenv(key + HOST_PREFIX);
-        String port = System.getenv(key + PORT_PREFIX);
+            // a service should have both the host and port defined
+            String host = System.getenv(key + HOST_PREFIX);
+            String port = System.getenv(key + PORT_PREFIX);
 
-        if (host != null && port != null) {
-            return host + ":" + port;
-        } else {
-            return defaultValue;
+            if (host != null && port != null) {
+                return host + ":" + port;
+            } else {
+                return defaultValue;
+            }
         }
+
+        return defaultValue;
     }
 }