Skip to content

Commit

Permalink
Remove exception mangling around LoggingTaskListener (elastic#102369)
Browse files Browse the repository at this point in the history
Replaces `ListenableActionFuture` with `SubscribableListener` at both
call sites.
  • Loading branch information
DaveCTurner authored Nov 20, 2023
1 parent 86e0599 commit 36a2f9b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.action.support.ListenableActionFuture;
import org.elasticsearch.action.support.SubscribableListener;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.index.reindex.AbstractBulkByScrollRequest;
Expand Down Expand Up @@ -64,9 +64,9 @@ protected RestChannelConsumer doPrepareRequest(RestRequest request, NodeClient c
if (validationException != null) {
throw validationException;
}
final var responseFuture = new ListenableActionFuture<BulkByScrollResponse>();
final var task = client.executeLocally(action, internal, responseFuture);
responseFuture.addListener(new LoggingTaskListener<>(task));
final var responseListener = new SubscribableListener<BulkByScrollResponse>();
final var task = client.executeLocally(action, internal, responseListener);
responseListener.addListener(new LoggingTaskListener<>(task));
return sendTask(client.getLocalNodeId(), task);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.ListenableActionFuture;
import org.elasticsearch.action.support.SubscribableListener;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.rest.BaseRestHandler;
Expand Down Expand Up @@ -65,9 +65,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
if (validationException != null) {
throw validationException;
}
final var responseFuture = new ListenableActionFuture<ForceMergeResponse>();
final var task = client.executeLocally(ForceMergeAction.INSTANCE, mergeRequest, responseFuture);
responseFuture.addListener(new LoggingTaskListener<>(task));
final var responseListener = new SubscribableListener<ForceMergeResponse>();
final var task = client.executeLocally(ForceMergeAction.INSTANCE, mergeRequest, responseListener);
responseListener.addListener(new LoggingTaskListener<>(task));
return sendTask(client.getLocalNodeId(), task);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public LoggingTaskListener(Task task) {
@Override
public void onResponse(Response response) {
logger.info("{} finished with response {}", task.getId(), response);

}

@Override
Expand Down

0 comments on commit 36a2f9b

Please sign in to comment.