Use ByteBuf.readSlice() in bgp-mvpn 53/96953/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Jul 2021 15:25:38 +0000 (17:25 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Jul 2021 17:18:26 +0000 (19:18 +0200)
readBytes() returns a ByteBuf, which needs to be be freed eventually
through ByteBuf.release() -- which we are not doing. Use readSlice()
instead.

JIRA: BGPCEP-973
Change-Id: Ide5af583cb33823a941093e6f9e7d5b61b4d2f3c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2350174ac2f6127e814307ff9940da0a2f904d13)

bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/tunnel/identifier/MldpP2mpLspParser.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/LeafADHandler.java

index cc4a1bde43f2c00ef2c38c50fdc1f1453e98e230..f4a44dc2402258734b19cba402861f3a64e13dc4 100644 (file)
@@ -92,9 +92,9 @@ public final class MldpP2mpLspParser extends AbstractTunnelIdentifier<MldpP2mpLs
         }
         mldpP2mpLsp.setAddressFamily(addressFamily);
         final short rootNodeLength = buffer.readUnsignedByte();
-        mldpP2mpLsp.setRootNodeAddress(parseIpAddress(rootNodeLength, buffer.readBytes(rootNodeLength)));
+        mldpP2mpLsp.setRootNodeAddress(parseIpAddress(rootNodeLength, buffer.readSlice(rootNodeLength)));
         final int opaqueValueLength = buffer.readUnsignedShort();
-        mldpP2mpLsp.setOpaqueValue(OpaqueUtil.parseOpaqueList(buffer.readBytes(opaqueValueLength)));
+        mldpP2mpLsp.setOpaqueValue(OpaqueUtil.parseOpaqueList(buffer.readSlice(opaqueValueLength)));
         return new MldpP2mpLspBuilder().setMldpP2mpLsp(mldpP2mpLsp.build()).build();
     }
 }
index f43f4cf71bb9a363feca61a623620576b9be545e..8550085515e86d3cd2fab1ff920962a211c3c5d4 100644 (file)
@@ -40,7 +40,7 @@ public final class LeafADHandler extends AbstractMvpnNlri<LeafADCase> {
     public LeafADCase parseMvpn(final ByteBuf buffer) {
         final NlriType type = NlriType.forValue(buffer.readUnsignedByte());
         final short length = buffer.readUnsignedByte();
-        final MvpnChoice key = SimpleMvpnNlriRegistry.getInstance().parseMvpn(type, buffer.readBytes(length));
+        final MvpnChoice key = SimpleMvpnNlriRegistry.getInstance().parseMvpn(type, buffer.readSlice(length));
         final LeafADRouteKey routeKey;
         if (type == NlriType.InterAsIPmsiAD) {
             routeKey = new InterAsIPmsiADCaseBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang