Committed by
Gerrit Code Review
Fix NPE when there's no secondary path.
Change-Id: I3bb8eeb2abf140d44cf4dc7186cf1bf316c23f70
Showing
3 changed files
with
8 additions
and
2 deletions
... | @@ -43,7 +43,7 @@ public interface DisjointPath extends Path { | ... | @@ -43,7 +43,7 @@ public interface DisjointPath extends Path { |
43 | /** | 43 | /** |
44 | * Gets secondary path. | 44 | * Gets secondary path. |
45 | * | 45 | * |
46 | - * @return secondary path | 46 | + * @return secondary path, or null if there is no secondary path available. |
47 | */ | 47 | */ |
48 | Path backup(); | 48 | Path backup(); |
49 | } | 49 | } | ... | ... |
... | @@ -482,6 +482,12 @@ public class DefaultTopology extends AbstractModel implements Topology { | ... | @@ -482,6 +482,12 @@ public class DefaultTopology extends AbstractModel implements Topology { |
482 | } | 482 | } |
483 | 483 | ||
484 | private DisjointPath networkDisjointPath(DisjointPathPair<TopologyVertex, TopologyEdge> path) { | 484 | private DisjointPath networkDisjointPath(DisjointPathPair<TopologyVertex, TopologyEdge> path) { |
485 | + if (!path.hasBackup()) { | ||
486 | + // There was no secondary path available. | ||
487 | + return new DefaultDisjointPath(CORE_PROVIDER_ID, | ||
488 | + (DefaultPath) networkPath(path.primary()), | ||
489 | + null); | ||
490 | + } | ||
485 | return new DefaultDisjointPath(CORE_PROVIDER_ID, | 491 | return new DefaultDisjointPath(CORE_PROVIDER_ID, |
486 | (DefaultPath) networkPath(path.primary()), | 492 | (DefaultPath) networkPath(path.primary()), |
487 | (DefaultPath) networkPath(path.secondary())); | 493 | (DefaultPath) networkPath(path.secondary())); | ... | ... |
... | @@ -66,7 +66,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa | ... | @@ -66,7 +66,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa |
66 | /** | 66 | /** |
67 | * Returns the secondary path. | 67 | * Returns the secondary path. |
68 | * | 68 | * |
69 | - * @return primary path | 69 | + * @return secondary path, or null if there is no secondary path available. |
70 | */ | 70 | */ |
71 | public Path<V, E> secondary() { | 71 | public Path<V, E> secondary() { |
72 | return secondary; | 72 | return secondary; | ... | ... |
-
Please register or login to post a comment