Fix NPE on route delete 74/18274/1
authorRobert Varga <rovarga@cisco.com>
Tue, 14 Apr 2015 14:39:45 +0000 (16:39 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 14 Apr 2015 14:40:57 +0000 (16:40 +0200)
Local testing has uncovered this:

2015-04-14 16:34:51,211 | INFO  | upCloseable-3-11 | BGPSessionImpl                   | 209 - org.opendaylight.bgpcep.bgp-rib-impl - 0.4.0.SNAPSHOT | Closing session: BGPSessionImpl{channel=[id: 0x0ff0457c, /127.0.0.2:36180 :> /127.0.0.1:179], state=IDLE}
2015-04-14 16:36:03,441 | ERROR | lt-dispatcher-16 | DataTreeChangeListenerActor      | 202 - org.opendaylight.controller.sal-distributed-datastore - 1.2.0.SNAPSHOT | Error notifying listener org.opendaylight.protocol.bgp.rib.impl.LocRibWriter@5917453f
java.lang.NullPointerException
        at org.opendaylight.protocol.bgp.rib.impl.LocRibWriter.onDataTreeChanged(LocRibWriter.java:183)[209:org.opendaylight.bgpcep.bgp-rib-impl:0.4.0.SNAPSHOT]
        at org.opendaylight.controller.cluster.datastore.DataTreeChangeListenerActor.dataChanged(DataTreeChangeListenerActor.java:53)[202:org.opendaylight.controller.sal-distributed-datastore:1.2.0.SNAPSHOT]

Which turns out to be a failure to check for deleted entry.

Change-Id: Ib4e0be69bbafdaf3e29698395a85224fdfa6c347
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java

index 38f5dcf9926de805ecd029662f0f85f52c4fb85b..bf63e03be0c5ea14f5cafe6adca20bf0998df3cb 100644 (file)
@@ -180,7 +180,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
             for (final PeerRole role : PeerRole.values()) {
                 final PeerExportGroup peerGroup = this.peerPolicyTracker.getPeerGroup(role);
                 if (peerGroup != null) {
-                    final ContainerNode attributes = entry.attributes();
+                    final ContainerNode attributes = entry == null ? null : entry.attributes();
                     final PeerId peerId = e.getKey().getPeerId();
                     final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(peerId, attributes);
                     for (final Entry<PeerId, YangInstanceIdentifier> pid : peerGroup.getPeers()) {