diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDecider.java index 5f05abe706f84..8bb18f3ea960d 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDecider.java @@ -137,9 +137,8 @@ private static boolean isReplacementSource(Metadata metadata, String nodeId) { if (nodeId == null || replacementOngoing(metadata) == false) { return false; } - return metadata.nodeShutdowns().values().stream() - .filter(shutdown -> shutdown.getType().equals(SingleNodeShutdownMetadata.Type.REPLACE)) - .anyMatch(shutdown -> shutdown.getNodeId().equals(nodeId)); + return metadata.nodeShutdowns().containsKey(nodeId) && + metadata.nodeShutdowns().get(nodeId).getType().equals(SingleNodeShutdownMetadata.Type.REPLACE); } /**