Bug fix - Do not create new next-objective if there are no
non-duplicate buckets to add.

Change-Id: I5bbf3f22225ae91efeed7f5987e771de209f725c
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
index 8d757aa..95f07b2 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
@@ -591,7 +591,7 @@
         } else if (!isBos && !this.srManager.getMplsEcmp()) {
             ns = NeighborSet.neighborSet(true, nextHops, true);
         }
-        log.info("Trying to get a nextObjId for mpls rule on device:{} to ns:{}",
+        log.debug("Trying to get a nextObjId for mpls rule on device:{} to ns:{}",
                   deviceId, ns);
         // If BoS == True, all forwarding is via L3 ECMP group.
         // If Bos == False, the forwarding can be via MPLS-ECMP group or through
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java
index 8637e0b..c93ad9b 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/Ofdpa2GroupHandler.java
@@ -1073,11 +1073,14 @@
             }
         });
 
-        if (!duplicateBuckets.isEmpty()) {
-            log.debug("Some buckets {} already exists in next id {}, duplicate buckets will be ignored.",
-                     duplicateBuckets, nextObjective.id());
-
-            // new next objective with new treatments
+        if (duplicateBuckets.isEmpty()) {
+            // use the original objective
+            objectiveToAdd = nextObjective;
+        } else if (!nonDuplicateBuckets.isEmpty()) {
+            // only use the non-duplicate buckets if there are any
+            log.debug("Some buckets {} already exist in next id {}, duplicate "
+                    + "buckets will be ignored.", duplicateBuckets, nextObjective.id());
+            // new next objective with non duplicate treatments
             NextObjective.Builder builder = DefaultNextObjective.builder()
                     .withType(nextObjective.type())
                     .withId(nextObjective.id())
@@ -1088,7 +1091,8 @@
             ObjectiveContext context = nextObjective.context().orElse(null);
             objectiveToAdd = builder.addToExisting(context);
         } else {
-            objectiveToAdd = nextObjective;
+            // buckets to add are already there - nothing to do
+            return;
         }
 
         if (nextObjective.type() == NextObjective.Type.HASHED) {