Brian O'Connor
Committed by Ray Milkey

Updating DefaultTrafficTreatment

- Updating EMPTY treatment to contain NOACTION
- Remove NOACTION when building treatment from existing treatment
- Putting NOACTION into immediate set if no actions exist

Change-Id: I408b6b8daf2a3d38604a900c09d7c15cc3994757
...@@ -31,7 +31,6 @@ import org.onosproject.net.flow.instructions.Instruction; ...@@ -31,7 +31,6 @@ import org.onosproject.net.flow.instructions.Instruction;
31 import org.onosproject.net.flow.instructions.Instructions; 31 import org.onosproject.net.flow.instructions.Instructions;
32 import org.onosproject.net.meter.MeterId; 32 import org.onosproject.net.meter.MeterId;
33 33
34 -import java.util.Collections;
35 import java.util.List; 34 import java.util.List;
36 import java.util.Objects; 35 import java.util.Objects;
37 36
...@@ -51,7 +50,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -51,7 +50,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
51 private final boolean hasClear; 50 private final boolean hasClear;
52 51
53 private static final DefaultTrafficTreatment EMPTY 52 private static final DefaultTrafficTreatment EMPTY
54 - = new DefaultTrafficTreatment(Collections.emptyList()); 53 + = new DefaultTrafficTreatment(ImmutableList.of(Instructions.createNoAction()));
55 private final Instructions.MeterInstruction meter; 54 private final Instructions.MeterInstruction meter;
56 55
57 /** 56 /**
...@@ -224,7 +223,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -224,7 +223,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
224 treatment.deferred().forEach(i -> add(i)); 223 treatment.deferred().forEach(i -> add(i));
225 224
226 immediate(); 225 immediate();
227 - treatment.immediate().forEach(i -> add(i)); 226 + treatment.immediate().stream()
227 + // NOACTION will get re-added if there are no other actions
228 + .filter(i -> i.type() != Instruction.Type.NOACTION)
229 + .forEach(i -> add(i));
228 230
229 clear = treatment.clearedDeferred(); 231 clear = treatment.clearedDeferred();
230 } 232 }
...@@ -476,6 +478,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -476,6 +478,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
476 public TrafficTreatment build() { 478 public TrafficTreatment build() {
477 if (deferred.size() == 0 && immediate.size() == 0 479 if (deferred.size() == 0 && immediate.size() == 0
478 && table == null && !clear) { 480 && table == null && !clear) {
481 + immediate();
479 noAction(); 482 noAction();
480 } 483 }
481 return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter); 484 return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter);
......
...@@ -416,6 +416,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -416,6 +416,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
416 description); 416 description);
417 } else if (instruction instanceof ModMplsLabelInstruction) { 417 } else if (instruction instanceof ModMplsLabelInstruction) {
418 return matchModMplsLabelInstruction(jsonInstruction, description); 418 return matchModMplsLabelInstruction(jsonInstruction, description);
419 + } else if (instruction instanceof NoActionInstruction) {
420 + return true;
419 } 421 }
420 422
421 return false; 423 return false;
......