sr-mcast NPE fix on vlan change
Change-Id: I9523e750fdb5fd76cf120ee2e64f3c63471c8132
(cherry picked from commit f053484c4a3310d93bbddfb4c8872cacebeb33c6)
diff --git a/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java b/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
index 584e51d..44a600c 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
@@ -56,6 +56,7 @@
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1107,7 +1108,12 @@
source, mcastIp);
return;
}
- ingressTransitPorts.put(source, ingressTransitPort(mcastIp, ingressDevice, source));
+ Set<PortNumber> ingressTransitPort = ingressTransitPort(mcastIp, ingressDevice, source);
+ if (ingressTransitPort.isEmpty()) {
+ log.warn("No transit ports to remove on device {}", ingressDevice);
+ return;
+ }
+ ingressTransitPorts.put(source, ingressTransitPort);
});
ingressTransitPorts.forEach((source, ports) -> ports.forEach(ingressTransitPort -> {
DeviceId ingressDevice = ingressDevices.stream()
@@ -1593,8 +1599,14 @@
ConnectPoint source) {
ImmutableSet.Builder<PortNumber> portBuilder = ImmutableSet.builder();
if (ingressDevice != null) {
- NextObjective nextObj = mcastNextObjStore.get(new McastStoreKey(mcastIp, ingressDevice,
- mcastUtils.assignedVlan(source))).value();
+ Versioned<NextObjective> nextObjVers = mcastNextObjStore.get(new McastStoreKey(mcastIp, ingressDevice,
+ mcastUtils.assignedVlan(source)));
+ if (nextObjVers == null) {
+ log.warn("Absent next objective for {}", new McastStoreKey(mcastIp, ingressDevice,
+ mcastUtils.assignedVlan(source)));
+ return portBuilder.build();
+ }
+ NextObjective nextObj = nextObjVers.value();
Set<PortNumber> ports = mcastUtils.getPorts(nextObj.next());
// Let's find out all the ingress-transit ports
for (PortNumber port : ports) {