Fix for Bugs 324 10/4410/4
authorEd Warnicke <eaw@cisco.com>
Sun, 19 Jan 2014 19:26:44 +0000 (13:26 -0600)
committerGerrit Code Review <gerrit@opendaylight.org>
Sun, 19 Jan 2014 22:49:33 +0000 (22:49 +0000)
Small fix to handle an NPE in TopologyMapping

Change-Id: I6040854ea281f501c62985b0a1fab709fda8c486
Signed-off-by: Ed Warnicke <eaw@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend

index cd4b8180374c4f2e2db80be70c71a33afe48ea0d..850c442b9b7374865cc19b372d9c87819cd1c43b 100644 (file)
@@ -20,9 +20,10 @@ import static extension org.opendaylight.controller.sal.compatibility.NodeMappin
 import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
 import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
+import org.slf4j.LoggerFactory
 
 class TopologyMapping {
 
 class TopologyMapping {
-    
+    private static val LOG = LoggerFactory.getLogger(TopologyMapping);
     private new() {
         throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
     }
     private new() {
         throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
     }
@@ -47,7 +48,20 @@ class TopologyMapping {
     }
     
     public static def toAdEdgeProperties(Edge e,TypeSafeDataReader reader) {
     }
     
     public static def toAdEdgeProperties(Edge e,TypeSafeDataReader reader) {
-        val nc = reader.readOperationalData(e.tailNodeConnector.toNodeConnectorRef.value as InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>)
+        val ncref = e.tailNodeConnector.toNodeConnectorRef
+        if(ncref == null) {
+            LOG.debug("Edge {} ncref {}",e,ncref)
+            return null;
+        }
+        val ncInstanceId = (ncref.value as InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>)
+        if(ncInstanceId == null) {
+            LOG.debug("Edge {} ncref {}",e,ncref)
+            return null;
+        }
+        val nc = reader.readOperationalData(ncInstanceId)
+        if(nc == null) {
+            return null;
+        }
         return nc.toADNodeConnectorProperties     
     }
     
         return nc.toADNodeConnectorProperties     
     }