diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteClusterCredentialsManager.java b/server/src/main/java/org/elasticsearch/transport/RemoteClusterCredentialsManager.java index bc2e3ade7440..7a6df38addba 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteClusterCredentialsManager.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteClusterCredentialsManager.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import static org.elasticsearch.transport.RemoteClusterService.REMOTE_CLUSTER_CREDENTIALS; @@ -37,7 +36,7 @@ public final synchronized UpdateRemoteClusterCredentialsResult updateClusterCred final Map newClusterCredentials = REMOTE_CLUSTER_CREDENTIALS.getAsMap(settings); if (clusterCredentials.isEmpty()) { setClusterCredentialsAndLog(newClusterCredentials); - return new UpdateRemoteClusterCredentialsResult(new TreeSet<>(newClusterCredentials.keySet()), Collections.emptySortedSet()); + return new UpdateRemoteClusterCredentialsResult(Set.copyOf(newClusterCredentials.keySet()), Collections.emptySet()); } final Set addedClusterAliases = Sets.difference(newClusterCredentials.keySet(), clusterCredentials.keySet());