Tal Nisan has uploaded a new change for review.

Change subject: core: Removed the LongCompat class
......................................................................

core: Removed the LongCompat class

Removed the LongCompat class and replaced all calls in Long.parse with
catching NumberFormatException, there are error handling anyway in each
of the references so it added no boilerplate code

Change-Id: If2b672f3406ce7b3316a5ff1b50379d92eedb062
Signed-off-by: Tal Nisan <[email protected]>
---
D 
backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/LongCompat.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/pm/VdsFenceOptions.java
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/RandomUtilsSeedingRule.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
M 
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Compat.gwt.xml
5 files changed, 12 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/66/11666/1

diff --git 
a/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/LongCompat.java
 
b/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/LongCompat.java
deleted file mode 100644
index c54264a..0000000
--- 
a/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/LongCompat.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.ovirt.engine.core.compat;
-
-/**
- * @deprecated Use org.apache.commons.lang.math.NumberUtils instead.
- */
-@Deprecated
-public class LongCompat {
-
-    public static Long tryParse(String value) {
-        try {
-            return new Long(value);
-        } catch (NumberFormatException e) {
-            // eat it and return null
-            return null;
-        }
-    }
-}
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/pm/VdsFenceOptions.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/pm/VdsFenceOptions.java
index d1145eb..64d350b 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/pm/VdsFenceOptions.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/pm/VdsFenceOptions.java
@@ -13,7 +13,6 @@
 import org.ovirt.engine.core.common.queries.ValueObjectMap;
 import org.ovirt.engine.core.compat.DoubleCompat;
 import org.ovirt.engine.core.compat.IntegerCompat;
-import org.ovirt.engine.core.compat.LongCompat;
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
 
@@ -513,10 +512,9 @@
                         }
                     }
                     else if (type.equalsIgnoreCase(LONG)) {
-                        final Long longVal = 
LongCompat.tryParse(fencingAgentInstanceOptions
-                                .get(key));
-                        if (longVal != null) {
-                            result = longVal;
+                        try {
+                            result = 
Long.parseLong(fencingAgentInstanceOptions.get(key));
+                        } catch (NumberFormatException e) {
                         }
                     }
                     else if (type.equalsIgnoreCase(DOUBLE)) {
diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/RandomUtilsSeedingRule.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/RandomUtilsSeedingRule.java
index 37ebcc6..51c12bd 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/RandomUtilsSeedingRule.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/RandomUtilsSeedingRule.java
@@ -2,7 +2,6 @@
 
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
-import org.ovirt.engine.core.compat.LongCompat;
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
 
@@ -22,11 +21,12 @@
     @Override
     public void starting(Description description) {
         String seedProperty = System.getProperty(RANDOM_SEED_PROPERTY);
-        Long seed = LongCompat.tryParse(seedProperty);
-        if (seed == null) {
-            log.infoFormat
-                    ("Property \"{0}\" was not set, using 
System.currentTimeMillis() as a seed.",
-                            RANDOM_SEED_PROPERTY);
+        Long seed;
+        try {
+            seed = Long.parseLong(seedProperty);
+        } catch (NumberFormatException e) {
+            log.infoFormat("Property \"{0}\" was not set, using 
System.currentTimeMillis() as a seed.",
+                    RANDOM_SEED_PROPERTY);
             seed = System.currentTimeMillis();
         }
         RandomUtils.instance().setSeed(seed);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
index bab303b..7381177 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
@@ -43,7 +43,6 @@
 import org.ovirt.engine.core.common.utils.EnumUtils;
 import org.ovirt.engine.core.compat.FormatException;
 import org.ovirt.engine.core.compat.Guid;
-import org.ovirt.engine.core.compat.LongCompat;
 import org.ovirt.engine.core.compat.RpmVersion;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
@@ -720,11 +719,10 @@
                                                      // need int.
                 stringValue = stringValue.split("[.]", -1)[0];
             }
-            final Long dec = LongCompat.tryParse(stringValue);
-            if (dec == null) {
+            try {
+                return Long.parseLong(stringValue);
+            } catch (NumberFormatException e) {
                 log.errorFormat("Failed to parse {0} value {1} to long", name, 
stringValue);
-            } else {
-                return dec;
             }
         }
         return null;
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Compat.gwt.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Compat.gwt.xml
index 8cdb8bb..e58b243 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Compat.gwt.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Compat.gwt.xml
@@ -16,7 +16,6 @@
                <include name="compat/Guid.java" />
                <include name="compat/NGuid.java" />
                <include name="compat/Serializable.java" />
-               <include name="compat/LongCompat.java" />
                <include name="compat/DoubleCompat.java" />
                <include name="compat/ApplicationException.java" />
                <!-- Required by common's utils -->


--
To view, visit http://gerrit.ovirt.org/11666
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2b672f3406ce7b3316a5ff1b50379d92eedb062
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tal Nisan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to