SwitchManager switch update NPE fix 44/10244/1
authorAdam Brcek <abrcek@cisco.com>
Mon, 25 Aug 2014 11:46:58 +0000 (13:46 +0200)
committerAdam Brcek <abrcek@cisco.com>
Mon, 25 Aug 2014 11:46:58 +0000 (13:46 +0200)
When new switch is discovered, NPE can be thrown when nodeConnectors is
null.

Signed-off-by: Adam Brcek <abrcek@cisco.com>
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/SwitchManager.java

index dffc3e207f5f89452084c71cecd8d1b0a15a04de..27056e418092a37b8a19acec4d9314c1104f1796 100644 (file)
@@ -407,18 +407,20 @@ public class SwitchManager implements AutoCloseable {
             
             List<NodeConnector> ports = switchNode.getNodeConnector();
             HashSet<NodeConnectorId> externalPorts = new HashSet<>();
-            for (NodeConnector nc : ports) {
-                FlowCapableNodeConnector fcnc = 
-                        nc.getAugmentation(FlowCapableNodeConnector.class);
-                if (fcnc == null || fcnc.getName() == null) continue;
-
-                if (fcnc.getName().matches(".*_(vxlan|tun)\\d+")) {
-                    tunnelPort = nc.getId();
-                }
-                if (nodeConfig != null) {
-                    for (String pattern : nodeConfig.getExternalInterfaces()) {
-                        if (fcnc.getName().matches(pattern))
-                            externalPorts.add(nc.getId());
+            if (ports != null) {
+                for (NodeConnector nc : ports) {
+                    FlowCapableNodeConnector fcnc = 
+                            nc.getAugmentation(FlowCapableNodeConnector.class);
+                    if (fcnc == null || fcnc.getName() == null) continue;
+
+                    if (fcnc.getName().matches(".*_(vxlan|tun)\\d+")) {
+                        tunnelPort = nc.getId();
+                    }
+                    if (nodeConfig != null) {
+                        for (String pattern : nodeConfig.getExternalInterfaces()) {
+                            if (fcnc.getName().matches(pattern))
+                                externalPorts.add(nc.getId());
+                        }
                     }
                 }
             }