Add switch null exception and log
Change-Id: Ibf8d7d05c2e86cd7d7f73c6bcd1eb3575ca5ed4b
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 177cf1a..846d142 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -360,6 +360,7 @@
DeviceId did = deviceId(uri(dpid));
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null) {
+ LOG.error("Switch {} is not found", dpid);
return;
}
@@ -415,6 +416,7 @@
DeviceId did = deviceId(uri(dpid));
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null) {
+ LOG.error("Switch {} is not found", dpid);
return;
}
final List<PortDescription> ports = buildPortDescriptions(sw);
@@ -835,6 +837,10 @@
}
} else if (((OFStatsReply) msg).getStatsType() == OFStatsType.EXPERIMENTER) {
OpenFlowSwitch sw = controller.getSwitch(dpid);
+ if (sw == null) {
+ LOG.error("Switch {} is not found", dpid);
+ break;
+ }
if (sw instanceof OpenFlowOpticalSwitch) {
// Optical switch uses experimenter stats message to update power
List<PortDescription> portDescs =