diff --git a/server/src/main/java/org/opensearch/identity/Subject.java b/server/src/main/java/org/opensearch/identity/Subject.java index a6bd7f9777481..349ce120244e4 100644 --- a/server/src/main/java/org/opensearch/identity/Subject.java +++ b/server/src/main/java/org/opensearch/identity/Subject.java @@ -36,7 +36,8 @@ public interface Subject { /** * runAs allows the caller to run a callable function as this subject */ - default void runAs(Callable callable) throws Exception { + default T runAs(Callable callable) throws Exception { callable.call(); + return null; }; } diff --git a/server/src/main/java/org/opensearch/identity/noop/NoopPluginSubject.java b/server/src/main/java/org/opensearch/identity/noop/NoopPluginSubject.java index f2d79d8a35d89..b8e25a1107afb 100644 --- a/server/src/main/java/org/opensearch/identity/noop/NoopPluginSubject.java +++ b/server/src/main/java/org/opensearch/identity/noop/NoopPluginSubject.java @@ -45,9 +45,10 @@ public void authenticate(AuthToken token) { } @Override - public void runAs(Callable callable) throws Exception { + public T runAs(Callable callable) throws Exception { try (ThreadContext.StoredContext ctx = threadPool.getThreadContext().stashContext()) { callable.call(); } + return null; } }