BUG-5844: Fix ComplexRouteEntry creation
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / impl / add / all / paths / ComplexRouteEntry.java
index 555d6b66dfc2d66f34c28ba66d4dd00d0d515618..e38bc8cff75c2290565b9249da76606188cace86 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.protocol.bgp.mode.api.BestPath;
 import org.opendaylight.protocol.bgp.mode.impl.OffsetMap;
 import org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath;
 import org.opendaylight.protocol.bgp.mode.impl.add.RouteKey;
+import org.opendaylight.protocol.bgp.mode.spi.RouteEntryUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -26,16 +27,15 @@ final class ComplexRouteEntry extends AbstractAllPathsRouteEntry {
         final RouteKey key = new RouteKey(routerId, remotePathId);
         final OffsetMap<RouteKey> map = getOffsets();
         final int offset = map.offsetOf(key);
-        final boolean ret = removeRoute(key, offset);
         this.values = map.removeValue(this.values, offset);
-        return ret;
+        return removeRoute(key, offset);
     }
 
     @Override
     public MapEntryNode createValue(final YangInstanceIdentifier.PathArgument routeId, final BestPath path) {
         final OffsetMap<RouteKey> map = getOffsets();
-        final int offset = map.offsetOf(((AddPathBestPath) path).getRouteKey());
-        return map.getValue(this.values, offset);
+        final MapEntryNode mapValues = map.getValue(this.values, map.offsetOf(((AddPathBestPath) path).getRouteKey()));
+        return RouteEntryUtil.createComplexRouteValue(routeId, path, mapValues);
     }
 
     @Override