Skip to content

Commit

Permalink
[ISSUE #11414]Optimize ServiceInfo.validate() to reduce memory usage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JorringHsiao authored Nov 24, 2023
1 parent c42981c commit 44b0891
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,14 @@ public boolean validate() {
return false;
}

List<Instance> validHosts = new ArrayList<>();
boolean existValidHosts = false;
for (Instance host : hosts) {
if (!host.isHealthy()) {
continue;
}

if (host.getWeight() > 0) {
validHosts.add(host);
if (host.isHealthy() && host.getWeight() > 0) {
existValidHosts = true;
break;
}
}
//No valid hosts, return false.
return !validHosts.isEmpty();
return existValidHosts;
}

@JsonIgnore
Expand Down

0 comments on commit 44b0891

Please sign in to comment.