karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch karaf-4.2.x updated: [KARAF-6270] Using default value in ClientConfig when using invalid value
Date Sun, 19 May 2019 04:57:00 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new bfeedc2  [KARAF-6270] Using default value in ClientConfig when using invalid value
bfeedc2 is described below

commit bfeedc28d2aedc3beb4bdb0a51c9842b405f36e0
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
AuthorDate: Sat May 18 07:56:59 2019 +0200

    [KARAF-6270] Using default value in ClientConfig when using invalid value
---
 .../main/java/org/apache/karaf/client/ClientConfig.java    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

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 ab2b402..8f57481 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -235,7 +235,12 @@ public class ClientConfig {
             if (val instanceof Number) {
                 return ((Number) val).intValue();
             } else if (val != null) {
-                return Integer.parseInt(val.toString());
+                try {
+                    return Integer.parseInt(val.toString());
+                } catch (Exception e) {
+                    System.err.println("Invalid value for " + key + ", using default " +
def);
+                    return def;
+                }
             }
         }
         return def;
@@ -247,7 +252,12 @@ public class ClientConfig {
             if (val instanceof Number) {
                 return ((Number) val).longValue();
             } else if (val != null) {
-                return Long.parseLong(val.toString());
+                try {
+                    return Long.parseLong(val.toString());
+                } catch (Exception e) {
+                    System.err.println("Invalid value for " + key + ", using default " +
def);
+                    return def;
+                }
             }
         }
         return def;


Mime
View raw message