From 8aca61c045e2f895f3f59104f5d028b36f59403d Mon Sep 17 00:00:00 2001 From: hanbj Date: Mon, 16 Aug 2021 12:35:50 +0800 Subject: [PATCH] Fix Stack Overflow in UnassignedInfo in Corner Case (#76480) We kept wrapping the collection over and over again which in extreme corner cases could lead to a SOE. Closes #76490 --- .../java/org/elasticsearch/cluster/routing/UnassignedInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java index 3937017f9ea04..03919553deb06 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java @@ -242,7 +242,7 @@ public UnassignedInfo(Reason reason, @Nullable String message, @Nullable Excepti this.failure = failure; this.failedAllocations = failedAllocations; this.lastAllocationStatus = Objects.requireNonNull(lastAllocationStatus); - this.failedNodeIds = Collections.unmodifiableSet(failedNodeIds); + this.failedNodeIds = org.elasticsearch.core.Set.copyOf(failedNodeIds); assert (failedAllocations > 0) == (reason == Reason.ALLOCATION_FAILED) : "failedAllocations: " + failedAllocations + " for reason " + reason; assert (message == null && failure != null) == false : "provide a message if a failure exception is provided";