File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
server/src/test/java/org/elasticsearch/cluster/service Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -299,7 +299,6 @@ public void testThreadContext() {
299299 }
300300
301301 try (ThreadContext .StoredContext ignored = threadPool .getThreadContext ().stashContext ()) {
302-
303302 final var expectedHeaders = new HashMap <String , String >();
304303 expectedHeaders .put (randomIdentifier (), randomIdentifier ());
305304 for (final var copiedHeader : Task .HEADERS_TO_COPY ) {
@@ -319,8 +318,10 @@ public void testThreadContext() {
319318 new AckedClusterStateUpdateTask (ackedRequest (ackTimeout , masterTimeout ), null ) {
320319 @ Override
321320 public ClusterState execute (ClusterState currentState ) {
322- assertTrue (threadPool .getThreadContext ().isSystemContext ());
323- assertEquals (Collections .emptyMap (), threadPool .getThreadContext ().getHeaders ());
321+ // the task is executed in the context in which the task was originally created.
322+ // note: this is typically not a system context.
323+ assertExpectedThreadContext (Map .of ());
324+
324325 expectedResponseHeaders .forEach (
325326 (name , values ) -> values .forEach (v -> threadPool .getThreadContext ().addResponseHeader (name , v ))
326327 );
You can’t perform that action at this time.
0 commit comments