As per [this comment](https://github.com/elastic/elasticsearch/pull/93375#discussion_r1093607808) the changes in #90977 may leak the thread context of the last-completing task into the response to the list-tasks API. We need to address this before these changes are released, which is planned for 8.7.0.
server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */
package org.elasticsearch.action.admin.cluster.tasks;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.test.ESIntegTestCase;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
public class ListTasksIT extends ESIntegTestCase {