Verify dataobject is Route 25/79325/2
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 8 Jan 2019 22:22:39 +0000 (23:22 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 9 Jan 2019 07:09:22 +0000 (08:09 +0100)
before casting when mapping from Normalized node

Change-Id: I4b28b50c42de2c577d325b1f42bd4c435c14592d
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java

index 74ec29e975ee3d21eec1e98a957b4bfd6fd4370b..3d38a30367341bc3755915e9d9dee7d6c93783eb 100644 (file)
@@ -257,16 +257,18 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
             final YangInstanceIdentifier routesPath = effectiveTablePath.node(childIdentifier);
             switch (child.getModificationType()) {
                 case DELETE:
-                case DISAPPEARED:
-                    processDeleteRouteTables(child, childIdentifier, ribSupport, routesPath);
-                    tx.delete(LogicalDatastoreType.OPERATIONAL, routesPath);
                     LOG.debug("Route deleted. routeId={}", routesPath);
+                    processTableChildenDelete(child, childIdentifier, tx, ribSupport, routesPath);
+                    break;
+                case DISAPPEARED:
+                    LOG.debug("Route disappeared. routeId={}", routesPath);
+                    processTableChildenDelete(child, childIdentifier, tx, ribSupport, routesPath);
                     break;
                 case UNMODIFIED:
                     // No-op
                     break;
                 case SUBTREE_MODIFIED:
-                    processModifiedRouteTables(child, childIdentifier,tx, ribSupport, routesPath, childDataAfter);
+                    processModifiedRouteTables(child, childIdentifier, tx, ribSupport, routesPath, childDataAfter);
                     break;
                 case APPEARED:
                 case WRITE:
@@ -279,6 +281,16 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
         }
     }
 
+    private void processTableChildenDelete(
+        final DataTreeCandidateNode child,
+        final PathArgument childIdentifier,
+        final DOMDataWriteTransaction tx,
+        final RIBSupport ribSupport,
+        final YangInstanceIdentifier routesPath) {
+        processDeleteRouteTables(child, childIdentifier, ribSupport, routesPath);
+        tx.delete(LogicalDatastoreType.OPERATIONAL, routesPath);
+    }
+
     private void processDeleteRouteTables(
         final DataTreeCandidateNode child,
         final PathArgument childIdentifier,
index 7e1625f7dab4bedcb5477b778b530abdb3cbff2c..2a5e8e612526ccf1845c73fbf0cdc8f81aca92ed 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.bgp.rib.spi;
 
+import static com.google.common.base.Verify.verify;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
@@ -524,7 +525,9 @@ public abstract class AbstractRIBSupport<
 
     @Override
     public R fromNormalizedNode(final YangInstanceIdentifier routePath, final NormalizedNode<?, ?> normalizedNode) {
-        return (R) this.mappingService.fromNormalizedNode(routePath, normalizedNode).getValue();
+        final DataObject node = this.mappingService.fromNormalizedNode(routePath, normalizedNode).getValue();
+        verify(node instanceof Route, "node %s is not a Route", node);
+        return (R) node;
     }
 
     @Override