From 0ef49bfa4ca28f512d2ec6212ffedc435e139886 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 22 Nov 2024 09:12:16 -0500 Subject: [PATCH] Move markAsSystemContext Signed-off-by: Craig Perkins --- .../main/java/org/opensearch/client/OriginSettingClient.java | 2 -- .../org/opensearch/common/util/concurrent/ThreadContext.java | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/client/OriginSettingClient.java b/server/src/main/java/org/opensearch/client/OriginSettingClient.java index 78a5a03890407..27d87227df7bc 100644 --- a/server/src/main/java/org/opensearch/client/OriginSettingClient.java +++ b/server/src/main/java/org/opensearch/client/OriginSettingClient.java @@ -71,8 +71,6 @@ protected void () -> in().threadPool().getThreadContext().stashWithOrigin(origin) ) ) { - ThreadContext threadContext = in().threadPool().getThreadContext(); - ThreadContextAccess.doPrivilegedVoid(threadContext::markAsSystemContext); super.doExecute(action, request, new ContextPreservingActionListener<>(supplier, listener)); } } diff --git a/server/src/main/java/org/opensearch/common/util/concurrent/ThreadContext.java b/server/src/main/java/org/opensearch/common/util/concurrent/ThreadContext.java index 75a7ef94978d4..4e43326cdbf27 100644 --- a/server/src/main/java/org/opensearch/common/util/concurrent/ThreadContext.java +++ b/server/src/main/java/org/opensearch/common/util/concurrent/ThreadContext.java @@ -227,6 +227,7 @@ public StoredContext stashWithOrigin(String origin) { sm.checkPermission(STASH_WITH_ORIGIN_THREAD_CONTEXT_PERMISSION); } final ThreadContext.StoredContext storedContext = stashContext(); + ThreadContextAccess.doPrivilegedVoid(this::markAsSystemContext); putTransient(ACTION_ORIGIN_TRANSIENT_NAME, origin); return storedContext; }