From 87eadafedde8bbc766c43505b89ca16f2508f059 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 19 Jun 2018 08:39:55 +0200 Subject: [PATCH] Preserve response headers on index creation listener Relates to #31408 and #31241 --- .../cluster/metadata/MetaDataCreateIndexService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index 35883cb208031..161aed9feef60 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -92,6 +92,7 @@ import java.util.function.Predicate; import java.util.stream.IntStream; +import static org.elasticsearch.action.support.ContextPreservingActionListener.wrapPreservingContext; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_CREATION_DATE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_INDEX_UUID; @@ -114,6 +115,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { private final AliasValidator aliasValidator; private final Environment env; private final IndexScopedSettings indexScopedSettings; + private final ThreadPool threadPool; private final ActiveShardsObserver activeShardsObserver; private final NamedXContentRegistry xContentRegistry; @@ -130,6 +132,7 @@ public MetaDataCreateIndexService(Settings settings, ClusterService clusterServi this.aliasValidator = aliasValidator; this.env = env; this.indexScopedSettings = indexScopedSettings; + this.threadPool = threadPool; this.activeShardsObserver = new ActiveShardsObserver(settings, clusterService, threadPool); this.xContentRegistry = xContentRegistry; } @@ -229,7 +232,7 @@ private void onlyCreateIndex(final CreateIndexClusterStateUpdateRequest request, logger, allocationService, request, - listener, + wrapPreservingContext(listener, threadPool.getThreadContext()), indicesService, aliasValidator, xContentRegistry,