diff --git a/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java b/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java index 6483126ac80ee..8749397323fdf 100644 --- a/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java +++ b/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -242,7 +243,7 @@ public Map apply(Map map) { builder.put(upsert.getKey(), upsert.getValue()); } - return builder; + return Collections.unmodifiableMap(builder); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java index f3e3a7979bd1c..4286a915e36c9 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java @@ -1214,8 +1214,8 @@ public Metadata apply(Metadata part) { builder.indices(updatedIndices); builder.templates(templates.apply(part.templates)); builder.customs(customs.apply(part.customs)); - builder.put(Collections.unmodifiableMap(immutableStateMetadata.apply(part.immutableStateMetadata))); - return builder.build(true); + builder.put(immutableStateMetadata.apply(part.immutableStateMetadata)); + return builder.build(); } }