BUG-5844: Fix ComplexRouteEntry creation
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / impl / base / BaseComplexRouteEntry.java
index 267ba24bd7d48f20a64e6ad7b0b544557385dc28..9dd20a71a912b79234d5906a5dea4d1cd0306438 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.mode.impl.base;
 import com.google.common.primitives.UnsignedInteger;
 import org.opendaylight.protocol.bgp.mode.api.BestPath;
 import org.opendaylight.protocol.bgp.mode.impl.OffsetMap;
+import org.opendaylight.protocol.bgp.mode.spi.RouteEntryUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -34,17 +35,17 @@ final class BaseComplexRouteEntry extends BaseAbstractRouteEntry {
     }
 
     @Override
-    public MapEntryNode createValue(final PathArgument routeId, final BestPath path) {
+    public boolean removeRoute(final UnsignedInteger routerId, final Long remotePathId) {
         final OffsetMap<UnsignedInteger> map = getOffsets();
-        return map.getValue(this.values, map.offsetOf(path.getRouterId()));
+        final int offset = map.offsetOf(routerId);
+        this.values = map.removeValue(this.values, offset);
+        return removeRoute(routerId, offset);
     }
 
     @Override
-    public boolean removeRoute(final UnsignedInteger routerId, final Long remotePathId) {
+    public MapEntryNode createValue(final PathArgument routeId, final BestPath path) {
         final OffsetMap<UnsignedInteger> map = getOffsets();
-        final int offset = map.offsetOf(routerId);
-        final boolean ret = removeRoute(routerId, offset);
-        this.values = map.removeValue(this.values, offset);
-        return ret;
+        final MapEntryNode mapValues = map.getValue(this.values, map.offsetOf(path.getRouterId()));
+        return RouteEntryUtil.createComplexRouteValue(routeId, path, mapValues);
     }
 }