diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index 6120391026a..cb3fc623357 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -5,37 +5,34 @@ */ package org.elasticsearch.xpack.graph.rest.action; -import static org.elasticsearch.rest.RestRequest.Method.GET; -import static org.elasticsearch.rest.RestRequest.Method.POST; -import static org.elasticsearch.xpack.graph.action.GraphExploreAction.INSTANCE; +import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.index.query.QueryParseContext; +import org.elasticsearch.indices.query.IndicesQueriesRegistry; +import org.elasticsearch.rest.RestController; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.rest.action.RestToXContentListener; +import org.elasticsearch.xpack.XPackClient; +import org.elasticsearch.xpack.graph.action.GraphExploreRequest; +import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost; +import org.elasticsearch.xpack.graph.action.Hop; +import org.elasticsearch.xpack.graph.action.VertexRequest; +import org.elasticsearch.xpack.rest.XPackRestHandler; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.common.ParseField; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.indices.query.IndicesQueriesRegistry; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.action.RestActions; -import org.elasticsearch.rest.action.RestToXContentListener; -import org.elasticsearch.xpack.XPackClient; -import org.elasticsearch.xpack.graph.action.GraphExploreRequest; -import org.elasticsearch.xpack.graph.action.Hop; -import org.elasticsearch.xpack.graph.action.VertexRequest; -import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost; -import org.elasticsearch.xpack.rest.XPackRestHandler; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.xpack.graph.action.GraphExploreAction.INSTANCE; /** * @see GraphExploreRequest @@ -88,14 +85,13 @@ public class RestGraphAction extends XPackRestHandler { if (request.hasParam(TIMEOUT_FIELD.getPreferredName())) { graphRequest.timeout(request.paramAsTime(TIMEOUT_FIELD.getPreferredName(), null)); } - if (!RestActions.hasBodyContent(request)) { + if (false == request.hasContentOrSourceParam()) { throw new ElasticsearchParseException("Body missing for graph request"); } - BytesReference qBytes = RestActions.getRestContent(request); Hop currentHop = graphRequest.createNextHop(null); - try(XContentParser parser = XContentFactory.xContent(qBytes).createParser(qBytes)) { + try (XContentParser parser = request.contentOrSourceParamParser()) { QueryParseContext context = new QueryParseContext(indicesQueriesRegistry, parser, parseFieldMatcher); XContentParser.Token token = parser.nextToken(); diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java index f73a8163a0d..89a9093e11c 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java @@ -59,7 +59,7 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler { throw new IllegalArgumentException("no [" + INTERVAL + "] for monitoring bulk request"); } - if (!RestActions.hasBodyContent(request)) { + if (false == request.hasContentOrSourceParam()) { throw new ElasticsearchParseException("no body content for monitoring bulk request"); } diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java index 12b91d53971..934e5716fc5 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.security.transport; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; @@ -213,7 +214,7 @@ public class SecurityServerTransportInterceptor implements TransportInterceptor assert filter != null; final Thread executingThread = Thread.currentThread(); - ActionListener.CheckedConsumer consumer = (x) -> { + CheckedConsumer consumer = (x) -> { final Executor executor; if (executingThread == Thread.currentThread()) { // only fork off if we get called on another thread this means we moved to