Rework parser infrastructure to support partial message processing
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / object / PCEPOpenObjectParser.java
index 4271137ca866a07ddd69d9cd4be654da5db3e695..d15e64eb792d71cbc362b75dfc503b15e18c4d7b 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
+import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -72,14 +72,15 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
        }
 
        @Override
-       public Open parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
+       public Object parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
                final int versionValue = ByteArray.copyBitsRange(bytes[VER_FLAGS_MF_OFFSET], VERSION_SF_OFFSET, VERSION_SF_LENGTH);
 
                if (versionValue != PCEP_VERSION) {
-                       throw new PCEPDocumentedException("Unsupported PCEP version " + versionValue, PCEPErrors.PCEP_VERSION_NOT_SUPPORTED);
+                       // LOG.info("Unsupported PCEP version {}", versionValue);
+                       return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED);
                }
                final OpenBuilder builder = new OpenBuilder();
                builder.setVersion(new ProtocolVersion((short) versionValue));