Browse Source

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.
Armin Braun 4 years ago
parent
commit
29d5674724

+ 3 - 3
server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/TransportForceMergeAction.java

@@ -70,13 +70,13 @@ public class TransportForceMergeAction
     @Override
     protected void shardOperation(ForceMergeRequest request, ShardRouting shardRouting, Task task,
                                   ActionListener<TransportBroadcastByNodeAction.EmptyResult> 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;
             }));
     }