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
Showing
7 changed files
with
7 additions
and
7 deletions
... | @@ -305,7 +305,7 @@ public class ReactiveForwarding { | ... | @@ -305,7 +305,7 @@ public class ReactiveForwarding { |
305 | try { | 305 | try { |
306 | String s = (String) properties.get(propertyName); | 306 | String s = (String) properties.get(propertyName); |
307 | value = isNullOrEmpty(s) ? value : Integer.parseInt(s.trim()); | 307 | value = isNullOrEmpty(s) ? value : Integer.parseInt(s.trim()); |
308 | - } catch (NumberFormatException e) { | 308 | + } catch (NumberFormatException | ClassCastException e) { |
309 | value = null; | 309 | value = null; |
310 | } | 310 | } |
311 | return value; | 311 | return value; | ... | ... |
... | @@ -105,7 +105,7 @@ public class BgpSessionManager implements BgpInfoService, BgpService { | ... | @@ -105,7 +105,7 @@ public class BgpSessionManager implements BgpInfoService, BgpService { |
105 | } else { | 105 | } else { |
106 | bgpPort = DEFAULT_BGP_PORT; | 106 | bgpPort = DEFAULT_BGP_PORT; |
107 | } | 107 | } |
108 | - } catch (Exception e) { | 108 | + } catch (NumberFormatException | ClassCastException e) { |
109 | bgpPort = DEFAULT_BGP_PORT; | 109 | bgpPort = DEFAULT_BGP_PORT; |
110 | } | 110 | } |
111 | log.debug("BGP port is set to {}", bgpPort); | 111 | log.debug("BGP port is set to {}", bgpPort); | ... | ... |
... | @@ -165,7 +165,7 @@ public class DefaultTopologyProvider extends AbstractProvider | ... | @@ -165,7 +165,7 @@ public class DefaultTopologyProvider extends AbstractProvider |
165 | s = (String) properties.get("maxIdleMs"); | 165 | s = (String) properties.get("maxIdleMs"); |
166 | newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s.trim()); | 166 | newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s.trim()); |
167 | 167 | ||
168 | - } catch (Exception e) { | 168 | + } catch (NumberFormatException | ClassCastException e) { |
169 | newMaxEvents = DEFAULT_MAX_EVENTS; | 169 | newMaxEvents = DEFAULT_MAX_EVENTS; |
170 | newMaxBatchMs = DEFAULT_MAX_BATCH_MS; | 170 | newMaxBatchMs = DEFAULT_MAX_BATCH_MS; |
171 | newMaxIdleMs = DEFAULT_MAX_IDLE_MS; | 171 | newMaxIdleMs = DEFAULT_MAX_IDLE_MS; | ... | ... |
... | @@ -146,7 +146,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid | ... | @@ -146,7 +146,7 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid |
146 | if (flag != null) { | 146 | if (flag != null) { |
147 | hostRemovalEnabled = flag.equals("true"); | 147 | hostRemovalEnabled = flag.equals("true"); |
148 | } | 148 | } |
149 | - } catch (Exception e) { | 149 | + } catch (ClassCastException e) { |
150 | hostRemovalEnabled = true; | 150 | hostRemovalEnabled = true; |
151 | } | 151 | } |
152 | log.info("Host removal is {}", hostRemovalEnabled ? "enabled" : "disabled"); | 152 | log.info("Host removal is {}", hostRemovalEnabled ? "enabled" : "disabled"); | ... | ... |
providers/null/device/src/main/java/org/onosproject/provider/nil/device/impl/NullDeviceProvider.java
... | @@ -157,7 +157,7 @@ public class NullDeviceProvider extends AbstractProvider implements DeviceProvid | ... | @@ -157,7 +157,7 @@ public class NullDeviceProvider extends AbstractProvider implements DeviceProvid |
157 | } | 157 | } |
158 | s = (String) properties.get("numPorts"); | 158 | s = (String) properties.get("numPorts"); |
159 | newPortNum = isNullOrEmpty(s) ? DEF_NUMPORTS : Integer.parseInt(s.trim()); | 159 | newPortNum = isNullOrEmpty(s) ? DEF_NUMPORTS : Integer.parseInt(s.trim()); |
160 | - } catch (Exception e) { | 160 | + } catch (NumberFormatException | ClassCastException e) { |
161 | log.warn(e.getMessage()); | 161 | log.warn(e.getMessage()); |
162 | newDevNum = numDevices; | 162 | newDevNum = numDevices; |
163 | newPortNum = numPorts; | 163 | newPortNum = numPorts; | ... | ... |
... | @@ -178,7 +178,7 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -178,7 +178,7 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider { |
178 | newRate = isNullOrEmpty(s) ? eventRate : Integer.parseInt(s.trim()); | 178 | newRate = isNullOrEmpty(s) ? eventRate : Integer.parseInt(s.trim()); |
179 | s = (String) properties.get("neighbors"); | 179 | s = (String) properties.get("neighbors"); |
180 | newNbor = isNullOrEmpty(s) ? neighbor : getNeighbor(s.trim()); | 180 | newNbor = isNullOrEmpty(s) ? neighbor : getNeighbor(s.trim()); |
181 | - } catch (Exception e) { | 181 | + } catch (NumberFormatException | ClassCastException e) { |
182 | log.warn(e.getMessage()); | 182 | log.warn(e.getMessage()); |
183 | newRate = eventRate; | 183 | newRate = eventRate; |
184 | newNbor = neighbor; | 184 | newNbor = neighbor; | ... | ... |
providers/null/packet/src/main/java/org/onosproject/provider/nil/packet/impl/NullPacketProvider.java
... | @@ -123,7 +123,7 @@ public class NullPacketProvider extends AbstractProvider implements | ... | @@ -123,7 +123,7 @@ public class NullPacketProvider extends AbstractProvider implements |
123 | try { | 123 | try { |
124 | String s = String.valueOf(properties.get("pktRate")); | 124 | String s = String.valueOf(properties.get("pktRate")); |
125 | newRate = isNullOrEmpty(s) ? pktRate : Integer.parseInt(s.trim()); | 125 | newRate = isNullOrEmpty(s) ? pktRate : Integer.parseInt(s.trim()); |
126 | - } catch (Exception e) { | 126 | + } catch (NumberFormatException | ClassCastException e) { |
127 | log.warn(e.getMessage()); | 127 | log.warn(e.getMessage()); |
128 | newRate = pktRate; | 128 | newRate = pktRate; |
129 | } | 129 | } | ... | ... |
-
Please register or login to post a comment