Fix for ONOS-5032 and ONOS-5034
Change-Id: Ib964252dd05754ce7069a7a82ccb1d1c29bfa978
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index 73d2a36..81c9bce 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -348,6 +348,26 @@
}
/**
+ * Get Long property from the propertyName
+ * Return null if propertyName is not found.
+ *
+ * @param properties properties to be looked up
+ * @param propertyName the name of the property to look up
+ * @return value when the propertyName is defined or return null
+ */
+ public static Long getLongProperty(Dictionary<?, ?> properties,
+ String propertyName) {
+ Long value;
+ try {
+ String s = get(properties, propertyName);
+ value = Strings.isNullOrEmpty(s) ? null : Long.valueOf(s);
+ } catch (NumberFormatException | ClassCastException e) {
+ value = null;
+ }
+ return value;
+ }
+
+ /**
* Suspends the current thread for a specified number of millis.
*
* @param ms number of millis