Merge "Fix for cache cleanup in protocol plugin on container deletion"
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / DiscoveryService.java
index 592e336b0be58541577b0dfd0c61c28a7178face..012807eee9ff622e5469a035b2a0e0e7b3294496 100644 (file)
@@ -560,10 +560,11 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
     private void addDiscovery(Node node) {
         Map<Long, ISwitch> switches = controller.getSwitches();
         ISwitch sw = switches.get(node.getID());
-        List<OFPhysicalPort> ports = sw.getEnabledPorts();
-        if (ports == null) {
+        if (sw == null) {
+            //switch could be removed by now, stop propagation
             return;
         }
+        List<OFPhysicalPort> ports = sw.getEnabledPorts();
         for (OFPhysicalPort port : ports) {
             NodeConnector nodeConnector = NodeConnectorCreator.createOFNodeConnector(port.getPortNumber(), node);
             if (!readyListHi.contains(nodeConnector)) {