Ray Milkey
Committed by Gerrit Code Review

STC fixes

- NPE when a switch has already been removed and an attempt is made
  to access stats on the switch.

- NPE in group provider if the system is in the process of shutting down.

- Lower ERROR to WARN when switch resources are not available.

Change-Id: I5b90ff328b19c2d661fde3a24e90614999c4c900
...@@ -159,7 +159,7 @@ final class ResourceDeviceListener implements DeviceListener { ...@@ -159,7 +159,7 @@ final class ResourceDeviceListener implements DeviceListener {
159 .map(adminService::register) 159 .map(adminService::register)
160 .ifPresent(success -> { 160 .ifPresent(success -> {
161 if (!success) { 161 if (!success) {
162 - log.error("Failed to register Bandwidth for {}", portPath.id()); 162 + log.warn("Failed to register Bandwidth for {}", portPath.id());
163 } 163 }
164 }); 164 });
165 165
......
...@@ -269,6 +269,10 @@ public class OpenFlowRuleProvider extends AbstractProvider ...@@ -269,6 +269,10 @@ public class OpenFlowRuleProvider extends AbstractProvider
269 Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); 269 Dpid dpid = Dpid.dpid(flowRule.deviceId().uri());
270 OpenFlowSwitch sw = controller.getSwitch(dpid); 270 OpenFlowSwitch sw = controller.getSwitch(dpid);
271 271
272 + if (sw == null) {
273 + return;
274 + }
275 +
272 FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad(); 276 FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad();
273 if (hasPayload(flowRuleExtPayLoad)) { 277 if (hasPayload(flowRuleExtPayLoad)) {
274 OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad()); 278 OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad());
...@@ -298,6 +302,10 @@ public class OpenFlowRuleProvider extends AbstractProvider ...@@ -298,6 +302,10 @@ public class OpenFlowRuleProvider extends AbstractProvider
298 Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); 302 Dpid dpid = Dpid.dpid(flowRule.deviceId().uri());
299 OpenFlowSwitch sw = controller.getSwitch(dpid); 303 OpenFlowSwitch sw = controller.getSwitch(dpid);
300 304
305 + if (sw == null) {
306 + return;
307 + }
308 +
301 FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad(); 309 FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad();
302 if (hasPayload(flowRuleExtPayLoad)) { 310 if (hasPayload(flowRuleExtPayLoad)) {
303 OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad()); 311 OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad());
......
...@@ -211,7 +211,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv ...@@ -211,7 +211,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
211 } 211 }
212 } 212 }
213 213
214 - if (groupStatsReply != null && groupDescStatsReply != null) { 214 + if (providerService != null && groupStatsReply != null) {
215 Collection<Group> groups = buildGroupMetrics(deviceId, 215 Collection<Group> groups = buildGroupMetrics(deviceId,
216 groupStatsReply, groupDescStatsReply); 216 groupStatsReply, groupDescStatsReply);
217 providerService.pushGroupMetrics(deviceId, groups); 217 providerService.pushGroupMetrics(deviceId, groups);
......