Handle null secondary path properly

Change-Id: Ie537c9fc7b6751ca071b3c7bf1e465bafe7913d3
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java b/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java
index ab05963..1f549a6 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java
@@ -20,7 +20,6 @@
 
 import java.util.List;
 import java.util.Objects;
-import static com.google.common.collect.ImmutableSet.of;
 
 /**
  * Default implementation of a network disjoint path pair.
@@ -40,7 +39,8 @@
      * @param path2      backup path
      */
     public DefaultDisjointPath(ProviderId providerId, DefaultPath path1, DefaultPath path2) {
-        super(providerId, path1.links(), path1.cost() + path2.cost());
+        // Note: cost passed to super will never be used
+        super(providerId, path1.links(), path1.cost());
         this.path1 = path1;
         this.path2 = path2;
     }
@@ -74,7 +74,9 @@
 
     @Override
     public int hashCode() {
-        return Objects.hash(of(path1, path2), src(), dst());
+        // Note: DisjointPath with primary and secondary swapped
+        // must result in same hashCode
+        return Objects.hash(Objects.hashCode(path1) + Objects.hashCode(path2), src(), dst());
     }
 
     @Override
@@ -84,7 +86,8 @@
         }
         if (obj instanceof DefaultDisjointPath) {
             final DefaultDisjointPath other = (DefaultDisjointPath) obj;
-            return Objects.equals(this.path1, other.path1) && Objects.equals(this.path2, other.path2);
+            return (Objects.equals(this.path1, other.path1) && Objects.equals(this.path2, other.path2)) ||
+                   (Objects.equals(this.path1, other.path2) && Objects.equals(this.path2, other.path1));
         }
         return false;
     }