Skip to content

Commit 115ee49

Browse files
committed
Minor code improvement.
1 parent 3d0819d commit 115ee49

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/inference/InferenceRunner.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ public class InferenceRunner {
2626
private final Client client;
2727
private final ThreadPool threadPool;
2828

29-
public InferenceRunner(Client client) {
29+
public InferenceRunner(Client client, ThreadPool threadPool) {
3030
this.client = client;
31-
// TODO: revisit the executor service instantiation and thread pool choice.
32-
this.threadPool = client.threadPool();
31+
this.threadPool = threadPool;
3332
}
3433

3534
public ThreadPool threadPool() {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/TransportEsqlQueryAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public TransportEsqlQueryAction(
155155
projectResolver,
156156
indexNameExpressionResolver,
157157
usageService,
158-
new InferenceRunner(client)
158+
new InferenceRunner(client, threadPool)
159159
);
160160

161161
this.computeService = new ComputeService(

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/inference/InferenceRunnerTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void shutdownThreadPool() {
6565
}
6666

6767
public void testResolveInferenceIds() throws Exception {
68-
InferenceRunner inferenceRunner = new InferenceRunner(mockClient());
68+
InferenceRunner inferenceRunner = new InferenceRunner(mockClient(), threadPool);
6969
List<InferencePlan<?>> inferencePlans = List.of(mockInferencePlan("rerank-plan"));
7070
SetOnce<InferenceResolution> inferenceResolutionSetOnce = new SetOnce<>();
7171

@@ -82,7 +82,7 @@ public void testResolveInferenceIds() throws Exception {
8282
}
8383

8484
public void testResolveMultipleInferenceIds() throws Exception {
85-
InferenceRunner inferenceRunner = new InferenceRunner(mockClient());
85+
InferenceRunner inferenceRunner = new InferenceRunner(mockClient(), threadPool);
8686
List<InferencePlan<?>> inferencePlans = List.of(
8787
mockInferencePlan("rerank-plan"),
8888
mockInferencePlan("rerank-plan"),
@@ -110,7 +110,7 @@ public void testResolveMultipleInferenceIds() throws Exception {
110110
}
111111

112112
public void testResolveMissingInferenceIds() throws Exception {
113-
InferenceRunner inferenceRunner = new InferenceRunner(mockClient());
113+
InferenceRunner inferenceRunner = new InferenceRunner(mockClient(), threadPool);
114114
List<InferencePlan<?>> inferencePlans = List.of(mockInferencePlan("missing-plan"));
115115

116116
SetOnce<InferenceResolution> inferenceResolutionSetOnce = new SetOnce<>();
@@ -132,7 +132,6 @@ public void testResolveMissingInferenceIds() throws Exception {
132132
@SuppressWarnings({ "unchecked", "raw-types" })
133133
private Client mockClient() {
134134
Client client = mock(Client.class);
135-
when(client.threadPool()).thenReturn(threadPool);
136135
doAnswer(i -> {
137136
Runnable sendResponse = () -> {
138137
GetInferenceModelAction.Request request = i.getArgument(1, GetInferenceModelAction.Request.class);

0 commit comments

Comments
 (0)