From ed7a29cf9d3e9e849fee94abbc82e0b5a86ce85c Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Fri, 13 Aug 2021 19:16:56 +0200 Subject: [PATCH] Fix Mutable Data Structure in SnapshotsInProgress (#76505) The feature info instances shouldn't be mutable to prevent accidental bugs down the line. --- .../java/org/elasticsearch/cluster/SnapshotsInProgress.java | 2 +- .../org/elasticsearch/snapshots/SnapshotFeatureInfo.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index 3500091e01edb..91783c06634ea 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -568,7 +568,7 @@ private Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, St this.partial = partial; this.indices = org.elasticsearch.core.Map.copyOf(indices); this.dataStreams = org.elasticsearch.core.List.copyOf(dataStreams); - this.featureStates = Collections.unmodifiableList(featureStates); + this.featureStates = org.elasticsearch.core.List.copyOf(featureStates); this.startTime = startTime; this.shards = shards; this.repositoryStateId = repositoryStateId; diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotFeatureInfo.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotFeatureInfo.java index 5278e041023b6..e1021b2c9cfcb 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotFeatureInfo.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotFeatureInfo.java @@ -44,12 +44,11 @@ public class SnapshotFeatureInfo implements Writeable, ToXContentObject { public SnapshotFeatureInfo(String pluginName, List indices) { this.pluginName = pluginName; - this.indices = indices; + this.indices = org.elasticsearch.core.List.copyOf(indices); } public SnapshotFeatureInfo(final StreamInput in) throws IOException { - this.pluginName = in.readString(); - this.indices = in.readStringList(); + this(in.readString(), in.readStringList()); } @Override