Use ByteBuf.readSlice() in bgp-mvpn 46/96946/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 15:28:48 +0000 (17:28 +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>
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 13c33fb5ae381c96e7ad1c6cacf55dd8dd6ca367..17e9b4bc9e025808cb3c9642bd6f9ff5d955dd2c 100644 (file)
@@ -39,7 +39,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