Check for null srcNodeId and srcNodeConnectorId 04/4004/2
authorEd Warnicke <eaw@cisco.com>
Fri, 3 Jan 2014 00:50:17 +0000 (16:50 -0800)
committerEd Warnicke <eaw@cisco.com>
Mon, 6 Jan 2014 12:40:55 +0000 (04:40 -0800)
In response to comment here:

https://git.opendaylight.org/gerrit/#/c/3926/2/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/utils/LLDPDiscoveryUtils.java

Change-Id: I19f17f97a74bb3e9e7a7f1837e3484a3c5d32f53
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/utils/LLDPDiscoveryUtils.java

index d5dee32..716b1f2 100644 (file)
@@ -61,12 +61,13 @@ public class LLDPDiscoveryUtils {
                         srcNodeId = new NodeId(srcNodeIdString);
                     }
                 }
-                
-                InstanceIdentifier<NodeConnector> srcInstanceId = InstanceIdentifier.builder(Nodes.class)
-                        .child(Node.class,new NodeKey(srcNodeId))
-                        .child(NodeConnector.class, new NodeConnectorKey(srcNodeConnectorId))
-                        .toInstance();
-                return new NodeConnectorRef(srcInstanceId);
+                if(srcNodeId != null && srcNodeConnectorId != null) {
+                    InstanceIdentifier<NodeConnector> srcInstanceId = InstanceIdentifier.builder(Nodes.class)
+                            .child(Node.class,new NodeKey(srcNodeId))
+                            .child(NodeConnector.class, new NodeConnectorKey(srcNodeConnectorId))
+                            .toInstance();
+                    return new NodeConnectorRef(srcInstanceId);
+                }
             } catch (Exception e) {
                 LOG.warn("Caught exception ", e);
             }