Yuta HIGUCHI
Committed by Yuta HIGUCHI

Fix NPE when there's no secondary path.

Change-Id: I3bb8eeb2abf140d44cf4dc7186cf1bf316c23f70
(cherry picked from commit c3d69f52)
......@@ -43,7 +43,7 @@ public interface DisjointPath extends Path {
/**
* Gets secondary path.
*
* @return secondary path
* @return secondary path, or null if there is no secondary path available.
*/
Path backup();
}
......
......@@ -482,6 +482,12 @@ public class DefaultTopology extends AbstractModel implements Topology {
}
private DisjointPath networkDisjointPath(DisjointPathPair<TopologyVertex, TopologyEdge> path) {
if (!path.hasBackup()) {
// There was no secondary path available.
return new DefaultDisjointPath(CORE_PROVIDER_ID,
(DefaultPath) networkPath(path.primary()),
null);
}
return new DefaultDisjointPath(CORE_PROVIDER_ID,
(DefaultPath) networkPath(path.primary()),
(DefaultPath) networkPath(path.secondary()));
......
......@@ -66,7 +66,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
/**
* Returns the secondary path.
*
* @return primary path
* @return secondary path, or null if there is no secondary path available.
*/
public Path<V, E> secondary() {
return secondary;
......