|
71 | 71 | import org.elasticsearch.index.shard.ShardId;
|
72 | 72 | import org.elasticsearch.indices.IndicesService;
|
73 | 73 | import org.elasticsearch.rest.BaseRestHandler;
|
74 |
| -import org.elasticsearch.rest.BytesRestResponse; |
75 | 74 | import org.elasticsearch.rest.RestController;
|
76 | 75 | import org.elasticsearch.rest.RestRequest;
|
77 |
| -import org.elasticsearch.rest.RestResponse; |
78 |
| -import org.elasticsearch.rest.action.RestBuilderListener; |
| 76 | +import org.elasticsearch.rest.action.RestToXContentListener; |
79 | 77 | import org.elasticsearch.script.FilterScript;
|
80 | 78 | import org.elasticsearch.script.ScoreScript;
|
81 | 79 | import org.elasticsearch.script.Script;
|
|
94 | 92 | import static org.elasticsearch.action.ValidateActions.addValidationError;
|
95 | 93 | import static org.elasticsearch.rest.RestRequest.Method.GET;
|
96 | 94 | import static org.elasticsearch.rest.RestRequest.Method.POST;
|
97 |
| -import static org.elasticsearch.rest.RestStatus.OK; |
98 | 95 |
|
99 | 96 | public class PainlessExecuteAction extends Action<PainlessExecuteAction.Response> {
|
100 | 97 |
|
@@ -612,13 +609,7 @@ public String getName() {
|
612 | 609 | @Override
|
613 | 610 | protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
614 | 611 | final Request request = Request.parse(restRequest.contentOrSourceParamParser());
|
615 |
| - return channel -> client.executeLocally(INSTANCE, request, new RestBuilderListener<Response>(channel) { |
616 |
| - @Override |
617 |
| - public RestResponse buildResponse(Response response, XContentBuilder builder) throws Exception { |
618 |
| - response.toXContent(builder, ToXContent.EMPTY_PARAMS); |
619 |
| - return new BytesRestResponse(OK, builder); |
620 |
| - } |
621 |
| - }); |
| 612 | + return channel -> client.executeLocally(INSTANCE, request, new RestToXContentListener<>(channel)); |
622 | 613 | }
|
623 | 614 | }
|
624 | 615 |
|
|
0 commit comments