karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: [KARAF-3494] Escape reference to other properties when client tries to load etc/org.apache.karaf.shell.cfg
Date Thu, 05 Feb 2015 14:00:33 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 07f885815 -> 27cca2d12


[KARAF-3494] Escape reference to other properties when client tries to load etc/org.apache.karaf.shell.cfg


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

Branch: refs/heads/karaf-3.0.x
Commit: 27cca2d124e4620de3993036bf969570fecd24fc
Parents: 07f8858
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Thu Feb 5 14:44:25 2015 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Thu Feb 5 14:47:26 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/karaf/client/ClientConfig.java   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/27cca2d1/client/src/main/java/org/apache/karaf/client/ClientConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/ClientConfig.java b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
index 444849d..a409a07 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -43,7 +43,18 @@ public class ClientConfig {
         Properties shellCfg = loadProps(new File(System.getProperty("karaf.etc"), "org.apache.karaf.shell.cfg"));
 
         host = shellCfg.getProperty("sshHost", "localhost");
-        port = Integer.parseInt(shellCfg.getProperty("sshPort", "8101"));
+        if (host.contains("${")) {
+            // if sshHost property contains a reference to another property (coming from
etc/config.properties
+            // or etc/custom.properties), we fall back to "localhost" default value
+            host = "localhost";
+        }
+        String portString = shellCfg.getProperty("sshPort", "8101");
+        if (portString.contains("${")) {
+            // if sshPort property contains a reference to another property (coming from
etc/config.properties
+            // or etc/custom.properties), we fall back to "8101" default value
+            portString = "8101";
+        }
+        port = Integer.parseInt(portString);
         level = SimpleLogger.WARN;
         retryAttempts = 0;
         retryDelay = 2;
@@ -162,7 +173,7 @@ public class ClientConfig {
             }
 
         } catch (Exception e) {
-                System.err.println("Could not load properties from: " + file + ", Reason:
" + e.getMessage());
+                System.err.println("Warning: could not load properties from: " + file + ",
Reason: " + e.getMessage());
         } finally {
             if (is != null) {
                 try {


Mime
View raw message