Fix few code issues
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / graph / PostAlgoPathValidator.java
index ec7a97e8e4ef4089597a2aa3d4c801dbb5df1473..61e7f145aa52e840d302b93e5cd0cae3b06e977a 100644 (file)
@@ -163,13 +163,13 @@ public class PostAlgoPathValidator {
         double latency = 0;
 
         for (PceGraphEdge edge : path.getEdgeList()) {
-            try {
-                latency += edge.link().getLatency();
-                LOG.debug("- In checkLatency: latency of {} = {} units", edge.link().getLinkId().getValue(), latency);
-            } catch (NullPointerException e) {
+            if (edge.link() == null || edge.link().getLatency() == null) {
                 LOG.warn("- In checkLatency: the link {} does not contain latency field",
                     edge.link().getLinkId().getValue());
+                return false;
             }
+            latency += edge.link().getLatency();
+            LOG.debug("- In checkLatency: latency of {} = {} units", edge.link().getLinkId().getValue(), latency);
         }
         return (latency < maxLatency);
     }