From ef8b1b5a3c6748b5e3d28bc2eacfc30b4ab10481 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 2 Aug 2021 13:14:55 +0200 Subject: [PATCH] Fix Force Merge Action Invoking a Listener Twice (#75897) Just a noisy thing, this isn't causing a bug since the listener is of the notify-once kind here but still. --- .../admin/indices/forcemerge/TransportForceMergeAction.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/TransportForceMergeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/TransportForceMergeAction.java index 80e50e8642c94..c8c76192b281f 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/TransportForceMergeAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/TransportForceMergeAction.java @@ -70,13 +70,13 @@ protected ForceMergeRequest readRequestFrom(StreamInput in) throws IOException { @Override protected void shardOperation(ForceMergeRequest request, ShardRouting shardRouting, Task task, ActionListener listener) { - threadPool.executor(ThreadPool.Names.FORCE_MERGE).execute(ActionRunnable.run(listener, + assert (task instanceof CancellableTask) == false; // TODO: add cancellation handling here once the task supports it + threadPool.executor(ThreadPool.Names.FORCE_MERGE).execute(ActionRunnable.supply(listener, () -> { - assert (task instanceof CancellableTask) == false; // TODO: add cancellation handling here once the task supports it IndexShard indexShard = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()) .getShard(shardRouting.shardId().id()); indexShard.forceMerge(request); - listener.onResponse(EmptyResult.INSTANCE); + return EmptyResult.INSTANCE; })); }