Pavlin Radoslavov
Committed by Ray Milkey

Fixed a bug when parsing configuration properties for ReactiveForwarding

by catching the appropriate exception.

Apparently, if a property is configured/enabled in file Foo.cfg, e.g.:
  flowTimeout = 10
then the corresponding object/value in the Dictionary returned by
ComponentContext.getProperties()
has class type String.

However, if the property is commented-out, e.g.:

then the Dictionary still contains an entry for "flowTimeout", but
its class type is Integer.

Also, updated similar code elsewhere that was catching the generic
Exception with catching more specific exception(s).

Change-Id: I33ec348eb9efe3188e22cfc8cee2bb704948726d
......@@ -305,7 +305,7 @@ public class ReactiveForwarding {
try {
String s = (String) properties.get(propertyName);
value = isNullOrEmpty(s) ? value : Integer.parseInt(s.trim());
} catch (NumberFormatException e) {
} catch (NumberFormatException | ClassCastException e) {
value = null;
}
return value;
......
......@@ -105,7 +105,7 @@ public class BgpSessionManager implements BgpInfoService, BgpService {
} else {
bgpPort = DEFAULT_BGP_PORT;
}
} catch (Exception e) {
} catch (NumberFormatException | ClassCastException e) {
bgpPort = DEFAULT_BGP_PORT;
}
log.debug("BGP port is set to {}", bgpPort);
......
......@@ -165,7 +165,7 @@ public class DefaultTopologyProvider extends AbstractProvider
s = (String) properties.get("maxIdleMs");
newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s.trim());
} catch (Exception e) {
} catch (NumberFormatException | ClassCastException e) {
newMaxEvents = DEFAULT_MAX_EVENTS;
newMaxBatchMs = DEFAULT_MAX_BATCH_MS;
newMaxIdleMs = DEFAULT_MAX_IDLE_MS;
......
......@@ -146,7 +146,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
if (flag != null) {
hostRemovalEnabled = flag.equals("true");
}
} catch (Exception e) {
} catch (ClassCastException e) {
hostRemovalEnabled = true;
}
log.info("Host removal is {}", hostRemovalEnabled ? "enabled" : "disabled");
......
......@@ -157,7 +157,7 @@ public class NullDeviceProvider extends AbstractProvider implements DeviceProvid
}
s = (String) properties.get("numPorts");
newPortNum = isNullOrEmpty(s) ? DEF_NUMPORTS : Integer.parseInt(s.trim());
} catch (Exception e) {
} catch (NumberFormatException | ClassCastException e) {
log.warn(e.getMessage());
newDevNum = numDevices;
newPortNum = numPorts;
......
......@@ -178,7 +178,7 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider {
newRate = isNullOrEmpty(s) ? eventRate : Integer.parseInt(s.trim());
s = (String) properties.get("neighbors");
newNbor = isNullOrEmpty(s) ? neighbor : getNeighbor(s.trim());
} catch (Exception e) {
} catch (NumberFormatException | ClassCastException e) {
log.warn(e.getMessage());
newRate = eventRate;
newNbor = neighbor;
......
......@@ -123,7 +123,7 @@ public class NullPacketProvider extends AbstractProvider implements
try {
String s = String.valueOf(properties.get("pktRate"));
newRate = isNullOrEmpty(s) ? pktRate : Integer.parseInt(s.trim());
} catch (Exception e) {
} catch (NumberFormatException | ClassCastException e) {
log.warn(e.getMessage());
newRate = pktRate;
}
......