Eliminate possible redundant update when rearranging candidate order in leadership manager

Change-Id: Id76345ab827c4b6f55114f3afacdbc334092818a
diff --git a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java
index df8dd2e..fa9d7cb 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java
@@ -2,6 +2,7 @@
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -350,8 +351,9 @@
     @Override
     public boolean makeTopCandidate(String path, NodeId nodeId) {
         Versioned<List<NodeId>> newCandidates = candidateMap.computeIf(path,
-                candidates -> (candidates != null && candidates.contains(nodeId)) ||
-                              (candidates != null && Objects.equals(nodeId, candidates.get(LEADER_CANDIDATE_POS))),
+                candidates -> candidates != null &&
+                              candidates.contains(nodeId) &&
+                              !nodeId.equals(Iterables.getFirst(candidates, null)),
                 (topic, candidates) -> {
                     List<NodeId> updatedCandidates = new ArrayList<>(candidates.size());
                     updatedCandidates.add(nodeId);