Fix removal of linkstate routes 34/4534/1
authorRobert Varga <rovarga@cisco.com>
Tue, 21 Jan 2014 22:35:03 +0000 (23:35 +0100)
committerRobert Varga <rovarga@cisco.com>
Tue, 21 Jan 2014 22:35:03 +0000 (23:35 +0100)
Fixes the following exception seen when processing MP_UNREACH:

java.lang.ClassCastException: org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder$DestinationLinkstateCaseImpl cannot be cast to org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateDestination
        at org.opendaylight.protocol.bgp.linkstate.LinkstateAdjRIBsIn.removeRoutes(LinkstateAdjRIBsIn.java:214) ~[na:na]
        at org.opendaylight.protocol.bgp.rib.impl.RIBImpl.updateTables(RIBImpl.java:132) ~[na:na]
        at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.onMessage(BGPPeer.java:46) ~[na:na]
        at org.opendaylight.protocol.bgp.rib.impl.BGPPeer.onMessage(BGPPeer.java:32) ~[na:na]
        at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.handleMessage(BGPSessionImpl.java:199) ~[na:na]
        at org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl.handleMessage(BGPSessionImpl.java:50) ~[na:na]
        at org.opendaylight.protocol.framework.AbstractProtocolSession.channelRead0(AbstractProtocolSession.java:45) ~[na:na]
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[bundlefile:na]
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [bundlefile:na]
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [bundlefile:na]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173) ~[na:na]
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [bundlefile:na]
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [bundlefile:na]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173) ~[na:na]
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [bundlefile:na]
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [bundlefile:na]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[bundlefile:na]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:100) ~[bundlefile:na]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:480) ~[bundlefile:na]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:447) ~[bundlefile:na]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:341) ~[bundlefile:na]
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) ~[bundlefile:na]
        at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]

Change-Id: I95d9b586ddeacbd7bc39500525e8877def604a4c
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/LinkstateAdjRIBsIn.java

index 8a6065a562a60c8a96e286aedf9df48751bbe3ce..2a2c03b698c78da34fb5734d445ca90d70ad421b 100644 (file)
@@ -42,6 +42,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.link
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpUnreachNlri;
@@ -211,8 +212,10 @@ final class LinkstateAdjRIBsIn extends AbstractAdjRIBsIn<CLinkstateDestination,
 
        @Override
        public void removeRoutes(final DataModificationTransaction trans, final Peer peer, final MpUnreachNlri nlri) {
-               final CLinkstateDestination key = (CLinkstateDestination) ((LinkstateDestination) nlri.getWithdrawnRoutes().getDestinationType()).getCLinkstateDestination();
+               final DestinationLinkstate keys = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase) nlri.getWithdrawnRoutes().getDestinationType()).getDestinationLinkstate();
 
-               super.remove(trans, peer, key);
+               for (CLinkstateDestination key : keys.getCLinkstateDestination()) {
+                       super.remove(trans, peer, key);
+               }
        }
 }