make sure we don't go ahead if no index request holds a pipeline id

This commit is contained in:
javanna 2016-01-11 14:44:39 +01:00 committed by Luca Cavanna
parent bac1206161
commit 21c89e6c5b
1 changed files with 16 additions and 5 deletions

View File

@ -58,7 +58,6 @@ public final class IngestActionFilter extends AbstractComponent implements Actio
@Override
public void apply(Task task, String action, ActionRequest request, ActionListener listener, ActionFilterChain chain) {
if (IndexAction.NAME.equals(action)) {
assert request instanceof IndexRequest;
IndexRequest indexRequest = (IndexRequest) request;
@ -70,10 +69,22 @@ public final class IngestActionFilter extends AbstractComponent implements Actio
if (BulkAction.NAME.equals(action)) {
assert request instanceof BulkRequest;
BulkRequest bulkRequest = (BulkRequest) request;
@SuppressWarnings("unchecked")
ActionListener<BulkResponse> actionListener = (ActionListener<BulkResponse>) listener;
processBulkIndexRequest(task, bulkRequest, action, chain, actionListener);
return;
boolean isIngestRequest = false;
for (ActionRequest actionRequest : bulkRequest.requests()) {
if (actionRequest instanceof IndexRequest) {
IndexRequest indexRequest = (IndexRequest) actionRequest;
if (Strings.hasText(indexRequest.pipeline())) {
isIngestRequest = true;
break;
}
}
}
if (isIngestRequest) {
@SuppressWarnings("unchecked")
ActionListener<BulkResponse> actionListener = (ActionListener<BulkResponse>) listener;
processBulkIndexRequest(task, bulkRequest, action, chain, actionListener);
return;
}
}
chain.proceed(task, action, request, listener);