BUG-3419 : fix calling get() on Absent value 53/22453/5
authorIveta Halanova <iveta.halanova@pantheon.sk>
Fri, 12 Jun 2015 11:43:05 +0000 (13:43 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 12 Jun 2015 13:10:00 +0000 (13:10 +0000)
When BGP shuts down, LocRIB receives and uptodate
change with no data attached causing an Exception.
Fix this by checking existence of the data.

Change-Id: Ibe1aeb8e7f02136be2c83be516e47833c1d8146a
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
Signed-off-by: Iveta Halanova <iveta.halanova@pantheon.sk>
(cherry-picked from 117ee238c19162335c50ef85114b05e87d50b538)

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java

index c480eda500dee8add4cfb65cb74f066c7792de4d..0c4228661bb5e4340609327189315ad9e4d6630a 100644 (file)
@@ -64,6 +64,7 @@ public class ApplicationPeer implements AutoCloseable, org.opendaylight.protocol
         final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
         LOG.debug("Received data change to ApplicationRib {}", changes);
         for (final DataTreeCandidate tc : changes) {
+            LOG.debug("Modification Type {}", tc.getRootNode().getModificationType());
             final YangInstanceIdentifier path = tc.getRootPath();
             final PathArgument lastArg = path.getLastPathArgument();
             Verify.verify(lastArg instanceof NodeIdentifierWithPredicates, "Unexpected type %s in path %s", lastArg.getClass(), path);
index ea503efaf09d422d129b779909ace6ffa8e7eec0..46047c642573bbf00b9a0ebb5e4b0ae68a546381 100644 (file)
@@ -138,9 +138,8 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
 
     private void update(final DOMDataWriteTransaction tx, final Collection<DataTreeCandidate> changes,
         final Map<RouteUpdateKey, AbstractRouteEntry> toUpdate) {
-
         for (final DataTreeCandidate tc : changes) {
-            // call out peer-role has changed
+            LOG.debug("Modification type {}", tc.getRootNode().getModificationType());
             final YangInstanceIdentifier rootPath = tc.getRootPath();
             final DataTreeCandidateNode rootNode = tc.getRootNode();
             final DataTreeCandidateNode roleChange =  rootNode.getModifiedChild(AbstractPeerRoleTracker.PEER_ROLE_NID);
@@ -163,9 +162,11 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
             final UnsignedInteger routerId = RouterIds.routerIdForPeerId(peerId);
             for (final DataTreeCandidateNode child : table.getChildNodes()) {
                 if ((Attributes.QNAME).equals(child.getIdentifier().getNodeType())) {
-                    // putting uptodate attribute in
-                    LOG.trace("Uptodate found for {}", child.getDataAfter());
-                    tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get());
+                    if (child.getDataAfter().isPresent()) {
+                        // putting uptodate attribute in
+                        LOG.trace("Uptodate found for {}", child.getDataAfter());
+                        tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get());
+                    }
                     continue;
                 }
                 for (final DataTreeCandidateNode route : this.ribSupport.changedRoutes(child)) {