Fix NPE if mod group cannot be found
Change-Id: Ifa84ebc3d6400f5813f444b70e49d7a896f5846b
(cherry picked from commit 43869817467e47c72f3c50acaf258661d0c09c7a)
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java
index 40aad0d..2c77127 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2GroupHandler.java
@@ -1453,6 +1453,10 @@
//first group key is the one we want to modify
GroupKey modGroupKey = chainsToRemove.get(0).peekFirst();
Group modGroup = groupService.getGroup(deviceId, modGroupKey);
+ if (modGroup == null) {
+ log.warn("removeBucket(): Attempt to modify non-existent group {} for device {}", modGroupKey, deviceId);
+ return;
+ }
for (Deque<GroupKey> foundChain : chainsToRemove) {
//second group key is the one we wish to remove the reference to
if (foundChain.size() < 2) {
@@ -1499,7 +1503,8 @@
.collect(Collectors.toList());
log.debug("Removing buckets from group id 0x{} pointing to group id(s) {} "
- + "for next id {} in device {}", Integer.toHexString(modGroup.id().id()),
+ + "for next id {} in device {}",
+ Integer.toHexString(modGroup.id().id()),
pointedGroupIds, nextObjective.id(), deviceId);
addPendingUpdateNextObjective(modGroupKey, nextObjective);
groupService.removeBucketsFromGroup(deviceId, modGroupKey,