From f8cf238079ba58969c01cdfdd6a9c5c977f6ec2c Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 30 May 2024 16:46:45 -0400 Subject: [PATCH] Only allow core to set the ExecutionContext Signed-off-by: Craig Perkins --- .../opensearch/common/util/concurrent/ExecutionContext.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/main/java/org/opensearch/common/util/concurrent/ExecutionContext.java b/server/src/main/java/org/opensearch/common/util/concurrent/ExecutionContext.java index bff824173df65..251454d8ec868 100644 --- a/server/src/main/java/org/opensearch/common/util/concurrent/ExecutionContext.java +++ b/server/src/main/java/org/opensearch/common/util/concurrent/ExecutionContext.java @@ -12,6 +12,9 @@ public class ExecutionContext { private final ThreadLocal context = new ThreadLocal<>(); public void set(String value) { + if (context.get() != null) { + throw new IllegalArgumentException("ExecutionContext already present"); + } context.set(value); }