Committed by
Gerrit Code Review
Handle null secondary path properly
Change-Id: Ie537c9fc7b6751ca071b3c7bf1e465bafe7913d3
Showing
1 changed file
with
7 additions
and
4 deletions
| ... | @@ -20,7 +20,6 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -20,7 +20,6 @@ import org.onosproject.net.provider.ProviderId; |
| 20 | 20 | ||
| 21 | import java.util.List; | 21 | import java.util.List; |
| 22 | import java.util.Objects; | 22 | import java.util.Objects; |
| 23 | -import static com.google.common.collect.ImmutableSet.of; | ||
| 24 | 23 | ||
| 25 | /** | 24 | /** |
| 26 | * Default implementation of a network disjoint path pair. | 25 | * Default implementation of a network disjoint path pair. |
| ... | @@ -40,7 +39,8 @@ public class DefaultDisjointPath extends DefaultPath implements DisjointPath { | ... | @@ -40,7 +39,8 @@ public class DefaultDisjointPath extends DefaultPath implements DisjointPath { |
| 40 | * @param path2 backup path | 39 | * @param path2 backup path |
| 41 | */ | 40 | */ |
| 42 | public DefaultDisjointPath(ProviderId providerId, DefaultPath path1, DefaultPath path2) { | 41 | public DefaultDisjointPath(ProviderId providerId, DefaultPath path1, DefaultPath path2) { |
| 43 | - super(providerId, path1.links(), path1.cost() + path2.cost()); | 42 | + // Note: cost passed to super will never be used |
| 43 | + super(providerId, path1.links(), path1.cost()); | ||
| 44 | this.path1 = path1; | 44 | this.path1 = path1; |
| 45 | this.path2 = path2; | 45 | this.path2 = path2; |
| 46 | } | 46 | } |
| ... | @@ -74,7 +74,9 @@ public class DefaultDisjointPath extends DefaultPath implements DisjointPath { | ... | @@ -74,7 +74,9 @@ public class DefaultDisjointPath extends DefaultPath implements DisjointPath { |
| 74 | 74 | ||
| 75 | @Override | 75 | @Override |
| 76 | public int hashCode() { | 76 | public int hashCode() { |
| 77 | - return Objects.hash(of(path1, path2), src(), dst()); | 77 | + // Note: DisjointPath with primary and secondary swapped |
| 78 | + // must result in same hashCode | ||
| 79 | + return Objects.hash(Objects.hashCode(path1) + Objects.hashCode(path2), src(), dst()); | ||
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | @Override | 82 | @Override |
| ... | @@ -84,7 +86,8 @@ public class DefaultDisjointPath extends DefaultPath implements DisjointPath { | ... | @@ -84,7 +86,8 @@ public class DefaultDisjointPath extends DefaultPath implements DisjointPath { |
| 84 | } | 86 | } |
| 85 | if (obj instanceof DefaultDisjointPath) { | 87 | if (obj instanceof DefaultDisjointPath) { |
| 86 | final DefaultDisjointPath other = (DefaultDisjointPath) obj; | 88 | final DefaultDisjointPath other = (DefaultDisjointPath) obj; |
| 87 | - return Objects.equals(this.path1, other.path1) && Objects.equals(this.path2, other.path2); | 89 | + return (Objects.equals(this.path1, other.path1) && Objects.equals(this.path2, other.path2)) || |
| 90 | + (Objects.equals(this.path1, other.path2) && Objects.equals(this.path2, other.path1)); | ||
| 88 | } | 91 | } |
| 89 | return false; | 92 | return false; |
| 90 | } | 93 | } | ... | ... |
-
Please register or login to post a comment