Skip to content

Commit

Permalink
No need to extend from StatusToXContentObject,
Browse files Browse the repository at this point in the history
if RestToXContentListener is used instead of RestStatusToXContentListener
  • Loading branch information
martijnvg committed Mar 4, 2019
1 parent 578c019 commit a1c380e
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.StatusToXContentObject;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.RestStatusToXContentListener;
import org.elasticsearch.rest.action.RestToXContentListener;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;

Expand All @@ -45,7 +44,6 @@

import static org.elasticsearch.ingest.common.IngestCommonPlugin.GROK_PATTERNS;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK;

public class GrokProcessorGetAction extends Action<GrokProcessorGetAction.Response> {

Expand All @@ -68,7 +66,7 @@ public ActionRequestValidationException validate() {
}
}

public static class Response extends ActionResponse implements StatusToXContentObject {
public static class Response extends ActionResponse implements ToXContentObject {
private Map<String, String> grokPatterns;

Response(Map<String, String> grokPatterns) {
Expand All @@ -88,11 +86,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder;
}

@Override
public RestStatus status() {
return OK;
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
Expand Down Expand Up @@ -136,7 +129,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
return channel -> client.executeLocally(INSTANCE, new Request(), new RestStatusToXContentListener<>(channel));
return channel -> client.executeLocally(INSTANCE, new Request(), new RestToXContentListener<>(channel));
}
}
}

0 comments on commit a1c380e

Please sign in to comment.