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;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.meter.MeterId;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
......@@ -51,7 +50,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
private final boolean hasClear;
private static final DefaultTrafficTreatment EMPTY
= new DefaultTrafficTreatment(Collections.emptyList());
= new DefaultTrafficTreatment(ImmutableList.of(Instructions.createNoAction()));
private final Instructions.MeterInstruction meter;
/**
......@@ -224,7 +223,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
treatment.deferred().forEach(i -> add(i));
immediate();
treatment.immediate().forEach(i -> add(i));
treatment.immediate().stream()
// NOACTION will get re-added if there are no other actions
.filter(i -> i.type() != Instruction.Type.NOACTION)
.forEach(i -> add(i));
clear = treatment.clearedDeferred();
}
......@@ -476,6 +478,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
public TrafficTreatment build() {
if (deferred.size() == 0 && immediate.size() == 0
&& table == null && !clear) {
immediate();
noAction();
}
return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter);
......
......@@ -416,6 +416,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
description);
} else if (instruction instanceof ModMplsLabelInstruction) {
return matchModMplsLabelInstruction(jsonInstruction, description);
} else if (instruction instanceof NoActionInstruction) {
return true;
}
return false;
......