Remove MessageParser.parseMessageBody(ByteBuf, int) 79/77979/5
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Nov 2018 13:34:34 +0000 (14:34 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 21 Nov 2018 09:34:49 +0000 (10:34 +0100)
This method is no longer the proper entrypoint, remove it and update
all parsers to implement the replacement.

JIRA: BGPCEP-359
Change-Id: I6fff6cf9f0275d9562c9e37ce55d34287251794b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/extensions/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/ParserTest.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPKeepAliveMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPNotificationMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPOpenMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPRouteRefreshMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPUpdateMessageParser.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/OpenTest.java
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/MessageParser.java

index 15130dec08fcbee4cfa8094761463def984c7194..d310fb7840e13f0a240db939e8881e38811e14c3 100644 (file)
@@ -155,7 +155,8 @@ public class ParserTest {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
         final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0),
             MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         final Class<? extends AddressFamily> afi = message.getAttributes()
             .augmentation(Attributes2.class).getMpUnreachNlri().getAfi();
@@ -324,7 +325,8 @@ public class ParserTest {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(1), MessageUtil.COMMON_HEADER_LENGTH);
         final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1),
             MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         final UpdateBuilder builder = new UpdateBuilder();
 
@@ -531,7 +533,8 @@ public class ParserTest {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
         final int messageLength = ByteArray
             .bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         final UpdateBuilder builder = new UpdateBuilder();
 
index 6e3994d0a2cb329b026ce44dc1e4eb9d10aa9509..a38f74e670c26d1be5c576ba038a767988dedd9d 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Keepalive;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.KeepaliveBuilder;
 import org.opendaylight.yangtools.yang.binding.Notification;
@@ -28,7 +29,8 @@ public final class BGPKeepAliveMessageParser implements MessageParser, MessageSe
     }
 
     @Override
-    public Keepalive parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
+    public Keepalive parseMessageBody(final ByteBuf body, final int messageLength,
+            final PeerSpecificParserConstraint constraint) throws BGPDocumentedException {
         if (body.isReadable()) {
             throw BGPDocumentedException.badMessageLength("Message length field not within valid range.",
                     messageLength);
index 132509ab779b1c3225281e9319f04591936729f0..856d4ec6bf43de00f5bd6997c9b1b8dfa50e7bc5 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Notify;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.NotifyBuilder;
@@ -66,7 +67,8 @@ public final class BGPNotificationMessageParser implements MessageParser, Messag
      * @throws BGPDocumentedException if parsing goes wrong
      */
     @Override
-    public Notify parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
+    public Notify parseMessageBody(final ByteBuf body, final int messageLength,
+            final PeerSpecificParserConstraint constraint) throws BGPDocumentedException {
         Preconditions.checkArgument(body != null, "Buffer cannot be null.");
         if (body.readableBytes() < ERROR_SIZE) {
             throw BGPDocumentedException.badMessageLength("Notification message too small.", messageLength);
index 4b5308b375b7cca0038ca4615f64b288b649e9d0..6e15108d1ac668681e4c5f79c64b535a3cbc67b2 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
 import org.opendaylight.protocol.bgp.parser.spi.ParameterRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Values;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
@@ -105,7 +106,8 @@ public final class BGPOpenMessageParser implements MessageParser, MessageSeriali
      * @throws BGPDocumentedException if the parsing was unsuccessful
      */
     @Override
-    public Open parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
+    public Open parseMessageBody(final ByteBuf body, final int messageLength,
+            final PeerSpecificParserConstraint constraint) throws BGPDocumentedException {
         Preconditions.checkArgument(body != null, "Buffer cannot be null.");
 
         if (body.readableBytes() < MIN_MSG_LENGTH) {
index e2c2cd652e0b9c1a6eddea271d14a0ba1002ed7d..e736e6797832323d81474c46e2ba41f3c733b4eb 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
 import org.opendaylight.protocol.bgp.parser.spi.MultiprotocolCapabilitiesUtil;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh;
@@ -75,7 +76,8 @@ public final class BGPRouteRefreshMessageParser implements MessageParser, Messag
      * @throws BGPDocumentedException if parsing goes wrong
      */
     @Override
-    public RouteRefresh parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
+    public RouteRefresh parseMessageBody(final ByteBuf body, final int messageLength,
+            final PeerSpecificParserConstraint constraint) throws BGPDocumentedException {
         Preconditions.checkArgument(body != null, "Body buffer cannot be null.");
         if (body.readableBytes() < TRIPLET_BYTE_SIZE) {
             throw BGPDocumentedException.badMessageLength("RouteRefresh message is too small.", messageLength);
index d8d859ce5450edc5556dde4a1b4447b60a31611a..42daa9f173a945609c117650aef58a07af078145 100755 (executable)
@@ -66,11 +66,6 @@ public final class BGPUpdateMessageParser implements MessageParser, MessageSeria
         this.reg = requireNonNull(reg);
     }
 
-    @Override
-    public Update parseMessageBody(final ByteBuf buffer, final int messageLength) throws BGPDocumentedException {
-        return parseMessageBody(buffer, messageLength, null);
-    }
-
     @Override
     public void serializeMessage(final Notification message, final ByteBuf bytes) {
         Preconditions.checkArgument(message instanceof Update, "Message needs to be of type Update");
index 1a283944099934dddea852fa2167821d281973c6..13e42257a288657b1ab7ce74274c35c4db5cd90b 100644 (file)
@@ -96,7 +96,8 @@ public class BGPParserTest {
 
     @BeforeClass
     public static void setUp() throws Exception {
-        updateParser = new BGPUpdateMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry());
+        updateParser = new BGPUpdateMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
+            .getAttributeRegistry());
         for (int i = 1; i <= COUNTER; i++) {
             final String name = "/up" + i + ".bin";
             try (final InputStream is = BGPParserTest.class.getResourceAsStream(name)){
@@ -115,7 +116,8 @@ public class BGPParserTest {
                 is.close();
             }
         }
-        updatesWithMultiplePath = HexDumpBGPFileParser.parseMessages(BGPParserTest.class.getResourceAsStream(multiPathHexFile));
+        updatesWithMultiplePath = HexDumpBGPFileParser.parseMessages(BGPParserTest.class.getResourceAsStream(
+            multiPathHexFile));
         constraint = mock(PeerSpecificParserConstraint.class);
         mpSupport = mock(MultiPathSupport.class);
         Mockito.doReturn(Optional.of(mpSupport)).when(constraint).getPeerConstraint(Mockito.any());
@@ -173,8 +175,10 @@ public class BGPParserTest {
     public void testGetUpdateMessage1() throws Exception {
 
         final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         // check fields
 
@@ -285,13 +289,16 @@ public class BGPParserTest {
     @Test
     public void testGetUpdateMessage3() throws Exception {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         final UpdateBuilder builder = new UpdateBuilder();
 
         // check nlri
-        final List<Nlri> nlris = Lists.newArrayList(new NlriBuilder().setPrefix(new Ipv4Prefix("172.16.0.0/21")).build());
+        final List<Nlri> nlris = Lists.newArrayList(new NlriBuilder().setPrefix(new Ipv4Prefix("172.16.0.0/21"))
+            .build());
         builder.setNlri(nlris);
         assertEquals(builder.getNlri(), message.getNlri());
 
@@ -382,8 +389,10 @@ public class BGPParserTest {
     @Test
     public void testGetUpdateMessage4() throws Exception {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(3), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         final UpdateBuilder builder = new UpdateBuilder();
 
@@ -457,11 +466,14 @@ public class BGPParserTest {
     @Test
     public void testGetUpdateMessage5() throws Exception {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(4), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         // attributes
-        final List<WithdrawnRoutes> withdrawnRoutes = Lists.newArrayList(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30")).build());
+        final List<WithdrawnRoutes> withdrawnRoutes = Lists.newArrayList(new WithdrawnRoutesBuilder()
+            .setPrefix(new Ipv4Prefix("172.16.0.4/30")).build());
 
         // check API message
         final Update expectedMessage = new UpdateBuilder().setWithdrawnRoutes(withdrawnRoutes).build();
@@ -485,8 +497,10 @@ public class BGPParserTest {
     @Test
     public void testEORIpv4() throws Exception {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(5), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
         assertEquals(new UpdateBuilder().build(), message);
 
@@ -512,11 +526,15 @@ public class BGPParserTest {
     @Test
     public void testEORIpv6() throws Exception {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
-        final Class<? extends AddressFamily> afi = message.getAttributes().augmentation(Attributes2.class).getMpUnreachNlri().getAfi();
-        final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().augmentation(Attributes2.class).getMpUnreachNlri().getSafi();
+        final Class<? extends AddressFamily> afi = message.getAttributes().augmentation(Attributes2.class)
+                .getMpUnreachNlri().getAfi();
+        final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().augmentation(Attributes2.class)
+                .getMpUnreachNlri().getSafi();
 
         assertEquals(Ipv6AddressFamily.class, afi);
         assertEquals(UnicastSubsequentAddressFamily.class, safi);
@@ -543,11 +561,15 @@ public class BGPParserTest {
     @Test
     public void testEORIpv6exLength() throws Exception {
         final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH,
+            LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            null);
 
-        final Class<? extends AddressFamily> afi = message.getAttributes().augmentation(Attributes2.class).getMpUnreachNlri().getAfi();
-        final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().augmentation(Attributes2.class).getMpUnreachNlri().getSafi();
+        final Class<? extends AddressFamily> afi = message.getAttributes().augmentation(Attributes2.class)
+                .getMpUnreachNlri().getAfi();
+        final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().augmentation(Attributes2.class)
+                .getMpUnreachNlri().getSafi();
 
         assertEquals(Ipv6AddressFamily.class, afi);
         assertEquals(UnicastSubsequentAddressFamily.class, safi);
@@ -605,8 +627,10 @@ public class BGPParserTest {
     @Test
     public void testUpdateMessageNlriAddPath() throws Exception {
         final byte[] body = ByteArray.cutBytes(updatesWithMultiplePath.get(0), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(updatesWithMultiplePath.get(0), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength, constraint);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(updatesWithMultiplePath.get(0),
+            MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            constraint);
 
         // check fields
 
@@ -691,13 +715,17 @@ public class BGPParserTest {
     @Test
     public void testUpdateMessageWithdrawAddPath() throws Exception {
         final byte[] body = ByteArray.cutBytes(updatesWithMultiplePath.get(1), MessageUtil.COMMON_HEADER_LENGTH);
-        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(updatesWithMultiplePath.get(1), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
-        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength, constraint);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(updatesWithMultiplePath.get(1),
+            MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
+            constraint);
 
         // attributes
         final List<WithdrawnRoutes> withdrawnRoutes = Lists.newArrayList();
-        withdrawnRoutes.add(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30")).setPathId(new PathId(1L)).build());
-        withdrawnRoutes.add(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30")).setPathId(new PathId(2L)).build());
+        withdrawnRoutes.add(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30"))
+            .setPathId(new PathId(1L)).build());
+        withdrawnRoutes.add(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30"))
+            .setPathId(new PathId(2L)).build());
 
         // check API message
         final Update expectedMessage = new UpdateBuilder().setWithdrawnRoutes(withdrawnRoutes).build();
index 832ab8f25bf3e41aed041fb156fadc90ed523e14..eeace784b216ce060b8986db2a6091bd372893cd 100644 (file)
@@ -52,7 +52,7 @@ public class OpenTest {
         new BGPOpenMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getParameterRegistry()).serializeMessage(open, msg);
         final byte[] temp = ByteArray.cutBytes(ByteArray.getAllBytes(msg), 19);
         final Open openResult = new BGPOpenMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
-            .getParameterRegistry()).parseMessageBody(Unpooled.copiedBuffer(temp), temp.length);
+            .getParameterRegistry()).parseMessageBody(Unpooled.copiedBuffer(temp), temp.length, null);
 
         assertEquals(open.getBgpIdentifier(),openResult.getBgpIdentifier());
         assertEquals(open.getHoldTimer(), openResult.getHoldTimer());
index 8aa884a3b369a585dcbd7ace15704ba779fe1129..7d461d41375e888840ab319554ad61073e478a8f 100644 (file)
@@ -17,28 +17,15 @@ import org.opendaylight.yangtools.yang.binding.Notification;
  * Common interface for message parser implementation.
  */
 public interface MessageParser {
-
-    /**
-     * Parse BGP Message from buffer.
-     *
-     * @param body Encoded BGP message in ByteBuf.
-     * @param messageLength Length of the BGP message.
-     * @return Parsed BGP Message body.
-     * @throws BGPDocumentedException
-     */
-    @Nonnull Notification parseMessageBody(@Nonnull ByteBuf body, int messageLength) throws BGPDocumentedException;
-
     /**
-     * Invokes {@link #parseMessageBody(ByteBuf, int)}, so the constraint is omitted. Override for specific parser behavior.
+     * Parse BGP Message from buffer, potentially applying peer-specific constraints. Implementations are free
      *
      * @param body Encoded BGP message in ByteBuf.
      * @param messageLength Length of the BGP message.
-     * @param constraint Peer specific constraints.
+     * @param constraint Peer specific constraints, implementations may ignore them.
      * @return Parsed BGP Message body.
      * @throws BGPDocumentedException
      */
-    @Nonnull default Notification parseMessageBody(@Nonnull final ByteBuf body, final int messageLength, @Nullable final PeerSpecificParserConstraint constraint)
-            throws BGPDocumentedException {
-        return parseMessageBody(body, messageLength);
-    }
+    @Nonnull Notification parseMessageBody(@Nonnull ByteBuf body, int messageLength,
+            @Nullable PeerSpecificParserConstraint constraint) throws BGPDocumentedException;
 }