Bug 4731: Routes from BGP application peer not populated to example-ipv4-topology... 12/36312/2
authorMilos Fabian <milfabia@cisco.com>
Wed, 16 Mar 2016 17:50:48 +0000 (18:50 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 24 Mar 2016 08:30:04 +0000 (08:30 +0000)
Write routes into the eff-rib-in only in a case when
there are some routes in data change, so do not
overwrite empty routes table created before.

Change-Id: Ib3718b4bdee2d738514a0248eee11f0e9c8afbe0
Signed-off-by: Milos Fabian <milfabia@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java

index f3a01c9a544e95d1f4722b3d1415717e05ebbff1..c4188cf1686d85e26e5044e4231679cc10884dfb 100644 (file)
@@ -163,12 +163,15 @@ final class EffectiveRibInWriter implements AutoCloseable {
         }
 
         private void writeRouteTables(final DataTreeCandidateNode child, final PathArgument childIdentifier, final DOMDataWriteTransaction tx, final RIBSupport ribSupport, final AbstractImportPolicy policy, final YangInstanceIdentifier childPath, final Optional<NormalizedNode<?, ?>> childDataAfter) {
-            tx.put(LogicalDatastoreType.OPERATIONAL, childPath, childDataAfter.get());
-            // Routes are special, as they may end up being filtered. The previous put conveniently
-            // ensured that we have them in at target, so a subsequent delete will not fail :)
             if (TABLE_ROUTES.equals(childIdentifier)) {
-                for (final DataTreeCandidateNode route : ribSupport.changedRoutes(child)) {
-                    processRoute(tx, ribSupport, policy, childPath, route);
+                final Collection<DataTreeCandidateNode> changedRoutes = ribSupport.changedRoutes(child);
+                if (!changedRoutes.isEmpty()) {
+                    tx.put(LogicalDatastoreType.OPERATIONAL, childPath, childDataAfter.get());
+                    // Routes are special, as they may end up being filtered. The previous put conveniently
+                    // ensured that we have them in at target, so a subsequent delete will not fail :)
+                    for (final DataTreeCandidateNode route : changedRoutes) {
+                        processRoute(tx, ribSupport, policy, childPath, route);
+                    }
                 }
             }
         }