Fixing host-to-host compiler not to produce any installables if one == two.
Change-Id: I369e747537ee140c4bb5d63169e516e9700a3361
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
index a9bee07..c3f46ef 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.net.intent.impl.compiler;
+import com.google.common.collect.ImmutableList;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -35,6 +36,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import static org.onosproject.net.flow.DefaultTrafficSelector.builder;
@@ -60,6 +62,11 @@
@Override
public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) {
+ // If source and destination are the same, there are never any installables.
+ if (Objects.equals(intent.one(), intent.two())) {
+ return ImmutableList.of();
+ }
+
boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint());
Path pathOne = getPath(intent, intent.one(), intent.two());
Path pathTwo = isAsymmetric ?