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 {
.map(adminService::register)
.ifPresent(success -> {
if (!success) {
log.error("Failed to register Bandwidth for {}", portPath.id());
log.warn("Failed to register Bandwidth for {}", portPath.id());
}
});
......
......@@ -269,6 +269,10 @@ public class OpenFlowRuleProvider extends AbstractProvider
Dpid dpid = Dpid.dpid(flowRule.deviceId().uri());
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null) {
return;
}
FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad();
if (hasPayload(flowRuleExtPayLoad)) {
OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad());
......@@ -298,6 +302,10 @@ public class OpenFlowRuleProvider extends AbstractProvider
Dpid dpid = Dpid.dpid(flowRule.deviceId().uri());
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null) {
return;
}
FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad();
if (hasPayload(flowRuleExtPayLoad)) {
OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad());
......
......@@ -211,7 +211,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
}
}
if (groupStatsReply != null && groupDescStatsReply != null) {
if (providerService != null && groupStatsReply != null) {
Collection<Group> groups = buildGroupMetrics(deviceId,
groupStatsReply, groupDescStatsReply);
providerService.pushGroupMetrics(deviceId, groups);
......