From c2388b5c74dd0463bbc6b0bb714b8566eeec3d33 Mon Sep 17 00:00:00 2001 From: Bukhtawar Khan Date: Sun, 12 Mar 2023 15:09:09 +0530 Subject: [PATCH] Add return to avoid unnecessary computation (#6615) Signed-off-by: Bukhtawar Khan --- .../admin/cluster/health/TransportClusterHealthAction.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java index 137baf7005b8c..d475826b059d8 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java @@ -283,6 +283,7 @@ private void executeHealth( if (request.ensureNodeWeighedIn()) { if (clusterHealthResponse.hasDiscoveredClusterManager() == false) { listener.onFailure(new ClusterManagerNotDiscoveredException("cluster-manager not discovered")); + return; } else { DiscoveryNode localNode = currentState.getNodes().getLocalNode(); // TODO: make this check more generic, check for node role instead