From f0496111661509fc34d301bc4f7e7d71fecaca11 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 4 May 2022 14:37:28 -0700 Subject: [PATCH] Remove remaining ImmutableOpen maps from shard stores response (#86427) The IndicesShardStoresResponse had ImmutableOpenInt map removed, but its use accidentally remained in serialization. Thankfully the format for immutable open maps are interchangable with read java Map. This commit switches to using the new readImmutableMap to read the store statuses. relates #86239 --- .../shards/IndicesShardStoresResponse.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java index 945f76fec13d4..7f3d811470c22 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java @@ -12,8 +12,6 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.DefaultShardOperationFailedException; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.ImmutableOpenIntMap; -import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -241,19 +239,15 @@ public IndicesShardStoresResponse(Map>> s } IndicesShardStoresResponse() { - this(ImmutableOpenMap.of(), Collections.emptyList()); + this(Map.of(), Collections.emptyList()); } public IndicesShardStoresResponse(StreamInput in) throws IOException { super(in); - storeStatuses = in.readImmutableOpenMap(StreamInput::readString, i -> { - int indexEntries = i.readVInt(); - ImmutableOpenIntMap.Builder> shardEntries = ImmutableOpenIntMap.builder(); - for (int shardCount = 0; shardCount < indexEntries; shardCount++) { - shardEntries.put(i.readInt(), i.readList(StoreStatus::new)); - } - return shardEntries.build(); - }); + storeStatuses = in.readImmutableMap( + StreamInput::readString, + i -> i.readImmutableMap(StreamInput::readInt, j -> j.readImmutableList(StoreStatus::new)) + ); failures = Collections.unmodifiableList(in.readList(Failure::readFailure)); }