netconf-console unit tests added
[netconf.git] / netconf / netconf-console / src / main / java / org / opendaylight / netconf / console / commands / NetconfCommandUtils.java
index 67024f910b005a9c8d4c28742c87761a4516c454..40ac48f17c633613afc9a1dd9be39db3ae5d86d0 100644 (file)
@@ -25,11 +25,13 @@ public class NetconfCommandUtils {
         if (Strings.isNullOrEmpty(devicePort)) {
             return false;
         }
-        Integer port = Integer.parseInt(devicePort);
-        if (port != null && port >= 0 && port <= 65535) {
-            return true;
+        Integer port;
+        try {
+            port = Integer.parseInt(devicePort);
+        } catch (NumberFormatException e) {
+          return false;
         }
-        return false;
+        return port >= 0 && port <= 65535;
     }
 
     public static boolean isIpValid(final String deviceIp) {