Keep using same iterator.

Change-Id: Icfdb9d79c188677dd89c851644ceb855e3bb9781
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
index 6dd4ebd..62c027a 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/ConnectivityIntentCompiler.java
@@ -154,14 +154,15 @@
 
         @Override
         public double weight(TopologyEdge edge) {
-            if (!constraints.iterator().hasNext()) {
-                return 1.0;
-            }
 
             // iterate over all constraints in order and return the weight of
             // the first one with fast fail over the first failure
             Iterator<Constraint> it = constraints.iterator();
 
+            if (!it.hasNext()) {
+                return 1.0;
+            }
+
             double cost = it.next().cost(edge.link(), resourceService::isAvailable);
             while (it.hasNext() && cost > 0) {
                 if (it.next().cost(edge.link(), resourceService::isAvailable) < 0) {