BUG-5084: BGPOpenConfigListener NPE 38/33538/1
authorClaudio D. Gasparini <cgaspari@cisco.com>
Tue, 26 Jan 2016 09:41:56 +0000 (10:41 +0100)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Tue, 26 Jan 2016 09:41:56 +0000 (10:41 +0100)
Fix by check wheter List<Neighbor> is null.

Change-Id: Ia332df95b52f7b792bdb0a815d696453f33a1a8d
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
bgp/openconfig-impl/src/main/java/org/opendaylight/protocol/bgp/openconfig/impl/moduleconfig/BGPOpenConfigListener.java

index 4990845adaf8e98802b707a5140463495ffe7ee5..80e0219c86aec70f81cc43f21a6799f1aa1190e2 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.openconfig.impl.moduleconfig;
 
 import com.google.common.base.Preconditions;
 import java.util.Collection;
+import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
@@ -77,9 +78,11 @@ public final class BGPOpenConfigListener implements DataTreeChangeListener<Bgp>,
         if (removedData instanceof Global) {
             ribImplProvider.onGlobalRemoved((Global) removedData);
         } else if (removedData instanceof Neighbors) {
-            final Neighbors neighbors = (Neighbors) removedData;
-            for (final Neighbor neighbor : neighbors.getNeighbor()) {
-                removeNeighbor(neighbor);
+            final List<Neighbor> neighbors = ((Neighbors) removedData).getNeighbor();
+            if( neighbors != null) {
+                for (final Neighbor neighbor : neighbors) {
+                    removeNeighbor(neighbor);
+                }
             }
         } else {
             LOG.info("Skipping unhandled removed data: {}", removedData);