From e686d304f48d225f923e44fd786dec61fbd0f676 Mon Sep 17 00:00:00 2001 From: Howard Date: Mon, 18 May 2020 22:31:29 +0800 Subject: [PATCH] Remove Dead Conditional from RoutingTable (#56870) `delta` is always positive here. --- .../org/elasticsearch/cluster/routing/RoutingTable.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java b/server/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java index cb3a82f80efed..35b19a9247e02 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java @@ -478,13 +478,8 @@ public Builder updateNumberOfReplicas(final int numberOfReplicas, final String[] builder.addReplica(); } } else if (currentNumberOfReplicas > numberOfReplicas) { - int delta = currentNumberOfReplicas - numberOfReplicas; - if (delta <= 0) { - // ignore, can't remove below the current one... - } else { - for (int i = 0; i < delta; i++) { - builder.removeReplica(); - } + for (int i = 0; i < (currentNumberOfReplicas - numberOfReplicas); i++) { + builder.removeReplica(); } } indicesRouting.put(index, builder.build());