You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2014/11/18 09:03:15 UTC

git commit: updated refs/heads/master to b008d78

Repository: cloudstack
Updated Branches:
  refs/heads/master bfe53d1b2 -> b008d78b5


CLOUDSTACK-7930, CLOUDSTACK-7931: Do not allow to set invalid values for global settings which are of type integer and float

This closes #41


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

Branch: refs/heads/master
Commit: b008d78b57d318336e8e36091e64d19966ea518b
Parents: bfe53d1
Author: Anshul Gangwar <an...@citrix.com>
Authored: Mon Nov 17 15:27:22 2014 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Tue Nov 18 13:36:21 2014 +0530

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java      | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b008d78b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 2ba6ac1..865edf6 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -725,6 +725,21 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             type = c.getType();
         }
 
+        String errMsg = null;
+        try {
+            if (type.equals(Integer.class)) {
+                errMsg = "There was error in trying to parse value: " + value + ". Please enter a valid integer value for parameter " + name;
+                Integer.parseInt(value);
+            } else if (type.equals(Float.class)) {
+                errMsg = "There was error in trying to parse value: " + value + ". Please enter a valid float value for parameter " + name;
+                Float.parseFloat(value);
+            }
+        } catch (Exception e) {
+            // catching generic exception as some throws NullPointerException and some throws NumberFormatExcpeion
+            s_logger.error(errMsg);
+            return errMsg;
+        }
+
         if (value == null) {
             if (type.equals(Boolean.class)) {
                 return "Please enter either 'true' or 'false'.";