Guard malformed intent by pre-condition check on instantiation
Change-Id: I90ca0fac2e3b68c4ca5b464777b0cdaa2227c2e5
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
index e480ee2..b07a3a6 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
@@ -26,6 +26,7 @@
import java.util.List;
+import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -75,8 +76,14 @@
super(id(PointToPointIntent.class, selector, treatment,
ingressPoint, egressPoint, constraints),
appId, null, selector, treatment, constraints);
- this.ingressPoint = checkNotNull(ingressPoint);
- this.egressPoint = checkNotNull(egressPoint);
+
+ checkNotNull(ingressPoint);
+ checkNotNull(egressPoint);
+ checkArgument(!ingressPoint.equals(egressPoint),
+ "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint);
+
+ this.ingressPoint = ingressPoint;
+ this.egressPoint = egressPoint;
}
/**