From c8f996320cb06c781029f7198368ba6978ce4339 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 1 Apr 2015 03:38:38 +0300 Subject: [PATCH] Remove unsafe options For quite some time now, our networking layer makes sure to create safe messages as in not using the shared buffers. This is great, and we should remove the old support for "unsafe" notion in our codebase. closes #10360 --- .../validate/query/ValidateQueryRequest.java | 22 ++----- .../query/ValidateQueryRequestBuilder.java | 12 +--- .../action/bulk/BulkProcessor.java | 8 +-- .../action/bulk/BulkRequest.java | 28 ++++---- .../action/bulk/BulkRequestBuilder.java | 8 +-- .../action/bulk/BulkShardRequest.java | 14 ---- .../action/count/CountRequest.java | 22 ++----- .../action/count/CountRequestBuilder.java | 10 +-- .../action/delete/TransportDeleteAction.java | 1 - .../deletebyquery/DeleteByQueryRequest.java | 19 ++---- .../DeleteByQueryRequestBuilder.java | 14 +--- .../action/exists/ExistsRequest.java | 22 ++----- .../action/exists/ExistsRequestBuilder.java | 10 +-- .../action/explain/ExplainRequest.java | 18 +---- .../action/explain/ExplainRequestBuilder.java | 4 +- .../action/index/IndexRequest.java | 41 ++---------- .../action/index/IndexRequestBuilder.java | 23 +------ .../action/index/TransportIndexAction.java | 1 - .../put/PutIndexedScriptRequest.java | 31 +-------- .../put/PutIndexedScriptRequestBuilder.java | 24 +------ .../action/mlt/MoreLikeThisRequest.java | 27 ++------ .../mlt/TransportMoreLikeThisAction.java | 3 +- .../percolate/MultiPercolateRequest.java | 8 +-- .../action/percolate/PercolateRequest.java | 28 +------- .../percolate/PercolateRequestBuilder.java | 18 +---- .../action/search/MultiSearchRequest.java | 12 ++-- .../action/search/SearchRequest.java | 65 ++----------------- .../action/search/SearchRequestBuilder.java | 25 +------ .../type/TransportSearchTypeAction.java | 1 - .../action/suggest/SuggestRequest.java | 30 +++------ .../broadcast/BroadcastOperationRequest.java | 8 --- .../TransportBroadcastOperationAction.java | 1 - .../ShardReplicationOperationRequest.java | 7 -- ...nsportIndexReplicationOperationAction.java | 4 -- ...nsportShardReplicationOperationAction.java | 3 - .../shard/SingleShardOperationRequest.java | 3 - .../TransportShardSingleOperationAction.java | 1 - .../termvectors/dfs/DfsOnlyRequest.java | 5 -- .../http/netty/NettyHttpRequest.java | 6 -- .../org/elasticsearch/rest/RestRequest.java | 5 -- .../query/RestValidateQueryAction.java | 2 +- .../warmer/put/RestPutWarmerAction.java | 2 +- .../rest/action/bulk/RestBulkAction.java | 2 +- .../rest/action/count/RestCountAction.java | 2 +- .../RestDeleteByQueryAction.java | 2 +- .../rest/action/exists/RestExistsAction.java | 2 +- .../action/explain/RestExplainAction.java | 4 +- .../rest/action/index/RestIndexAction.java | 2 +- .../action/mlt/RestMoreLikeThisAction.java | 2 +- .../percolate/RestMultiPercolateAction.java | 2 +- .../action/percolate/RestPercolateAction.java | 4 +- .../script/RestPutIndexedScriptAction.java | 2 +- .../action/search/RestMultiSearchAction.java | 2 +- .../rest/action/search/RestSearchAction.java | 4 +- .../action/suggest/RestSuggestAction.java | 2 +- .../elasticsearch/script/ScriptService.java | 4 +- .../action/bulk/BulkIntegrationTests.java | 2 +- .../action/bulk/BulkRequestTests.java | 12 ++-- .../action/mlt/MoreLikeThisRequestTests.java | 1 - .../MultiPercolatorRequestTests.java | 4 +- .../search/MultiSearchRequestTests.java | 6 +- .../org/elasticsearch/document/BulkTests.java | 22 +++---- .../index/IndexRequestBuilderTests.java | 2 +- .../index/query/TemplateQueryTest.java | 6 +- .../elasticsearch/rest/RestRequestTests.java | 5 -- .../search/geo/GeoFilterTests.java | 2 +- .../test/rest/FakeRestRequest.java | 5 -- 67 files changed, 138 insertions(+), 561 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java index abacb77a55c..61e6bb81d8d 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java @@ -47,7 +47,6 @@ import java.util.Map; public class ValidateQueryRequest extends BroadcastOperationRequest { private BytesReference source; - private boolean sourceUnsafe; private boolean explain; @@ -74,14 +73,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest implements Composite * (for example, if no id is provided, one will be generated, or usage of the create flag). */ public BulkRequest add(IndexRequest request) { - request.beforeLocalFork(); return internalAdd(request, null); } public BulkRequest add(IndexRequest request, @Nullable Object payload) { - request.beforeLocalFork(); return internalAdd(request, payload); } @@ -222,32 +220,32 @@ public class BulkRequest extends ActionRequest implements Composite /** * Adds a framed data in binary format */ - public BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe) throws Exception { - return add(data, from, length, contentUnsafe, null, null); + public BulkRequest add(byte[] data, int from, int length) throws Exception { + return add(data, from, length, null, null); } /** * Adds a framed data in binary format */ - public BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception { - return add(new BytesArray(data, from, length), contentUnsafe, defaultIndex, defaultType); + public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception { + return add(new BytesArray(data, from, length), defaultIndex, defaultType); } /** * Adds a framed data in binary format */ - public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception { - return add(data, contentUnsafe, defaultIndex, defaultType, null, null, true); + public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception { + return add(data, defaultIndex, defaultType, null, null, true); } /** * Adds a framed data in binary format */ - public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws Exception { - return add(data, contentUnsafe, defaultIndex, defaultType, null, null, allowExplicitIndex); + public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws Exception { + return add(data, defaultIndex, defaultType, null, null, allowExplicitIndex); } - public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable Object payload, boolean allowExplicitIndex) throws Exception { + public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable Object payload, boolean allowExplicitIndex) throws Exception { XContent xContent = XContentFactory.xContent(data); int from = 0; int length = data.length(); @@ -336,20 +334,20 @@ public class BulkRequest extends ActionRequest implements Composite } // order is important, we set parent after routing, so routing will be set to parent if not set explicitly // we use internalAdd so we don't fork here, this allows us not to copy over the big byte array to small chunks - // of index request. All index requests are still unsafe if applicable. + // of index request. if ("index".equals(action)) { if (opType == null) { internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).timestamp(timestamp).ttl(ttl).version(version).versionType(versionType) - .source(data.slice(from, nextMarker - from), contentUnsafe), payload); + .source(data.slice(from, nextMarker - from)), payload); } else { internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).timestamp(timestamp).ttl(ttl).version(version).versionType(versionType) .create("create".equals(opType)) - .source(data.slice(from, nextMarker - from), contentUnsafe), payload); + .source(data.slice(from, nextMarker - from)), payload); } } else if ("create".equals(action)) { internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).timestamp(timestamp).ttl(ttl).version(version).versionType(versionType) .create(true) - .source(data.slice(from, nextMarker - from), contentUnsafe), payload); + .source(data.slice(from, nextMarker - from)), payload); } else if ("update".equals(action)) { UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).parent(parent).retryOnConflict(retryOnConflict) .version(version).versionType(versionType) diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java b/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java index 27fe9a41040..4ce8366dea5 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java @@ -96,16 +96,16 @@ public class BulkRequestBuilder extends ActionRequestBuilder { private String preference; private BytesReference source; - private boolean sourceUnsafe; private String[] types = Strings.EMPTY_ARRAY; @@ -89,14 +88,6 @@ public class CountRequest extends BroadcastOperationRequest { return validationException; } - @Override - protected void beforeStart() { - if (sourceUnsafe) { - source = source.copyBytesArray(); - sourceUnsafe = false; - } - } - /** * The minimum score of the documents to include in the count. */ @@ -125,7 +116,6 @@ public class CountRequest extends BroadcastOperationRequest { */ public CountRequest source(QuerySourceBuilder sourceBuilder) { this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - this.sourceUnsafe = false; return this; } @@ -144,7 +134,6 @@ public class CountRequest extends BroadcastOperationRequest { public CountRequest source(XContentBuilder builder) { this.source = builder.bytes(); - this.sourceUnsafe = false; return this; } @@ -154,7 +143,6 @@ public class CountRequest extends BroadcastOperationRequest { */ public CountRequest source(String querySource) { this.source = new BytesArray(querySource); - this.sourceUnsafe = false; return this; } @@ -162,19 +150,18 @@ public class CountRequest extends BroadcastOperationRequest { * The source to execute. */ public CountRequest source(byte[] querySource) { - return source(querySource, 0, querySource.length, false); + return source(querySource, 0, querySource.length); } /** * The source to execute. */ - public CountRequest source(byte[] querySource, int offset, int length, boolean unsafe) { - return source(new BytesArray(querySource, offset, length), unsafe); + public CountRequest source(byte[] querySource, int offset, int length) { + return source(new BytesArray(querySource, offset, length)); } - public CountRequest source(BytesReference querySource, boolean unsafe) { + public CountRequest source(BytesReference querySource) { this.source = querySource; - this.sourceUnsafe = unsafe; return this; } @@ -246,7 +233,6 @@ public class CountRequest extends BroadcastOperationRequest { minScore = in.readFloat(); routing = in.readOptionalString(); preference = in.readOptionalString(); - sourceUnsafe = false; source = in.readBytesReference(); types = in.readStringArray(); terminateAfter = in.readVInt(); diff --git a/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java b/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java index 298af7a88c4..6d1566797c1 100644 --- a/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/count/CountRequestBuilder.java @@ -112,15 +112,7 @@ public class CountRequestBuilder extends BroadcastOperationRequestBuilder listener) { if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) { - request.beforeLocalFork(); createIndexAction.execute(new CreateIndexRequest(request).index(request.index()).cause("auto(delete api)").masterNodeTimeout(request.timeout()), new ActionListener() { @Override public void onResponse(CreateIndexResponse result) { diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java b/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java index 70222b6f0ed..7386c9e9449 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java @@ -56,7 +56,6 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { private BytesReference source; - private boolean sourceUnsafe; private String[] types = Strings.EMPTY_ARRAY; @Nullable @@ -94,9 +93,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { private String preference; private BytesReference source; - private boolean sourceUnsafe; private String[] types = Strings.EMPTY_ARRAY; @@ -74,14 +73,6 @@ public class ExistsRequest extends BroadcastOperationRequest { return validationException; } - @Override - protected void beforeStart() { - if (sourceUnsafe) { - source = source.copyBytesArray(); - sourceUnsafe = false; - } - } - /** * The minimum score of the documents to include in the count. */ @@ -145,7 +136,6 @@ public class ExistsRequest extends BroadcastOperationRequest { */ public ExistsRequest source(QuerySourceBuilder sourceBuilder) { this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - this.sourceUnsafe = false; return this; } @@ -164,7 +154,6 @@ public class ExistsRequest extends BroadcastOperationRequest { public ExistsRequest source(XContentBuilder builder) { this.source = builder.bytes(); - this.sourceUnsafe = false; return this; } @@ -174,7 +163,6 @@ public class ExistsRequest extends BroadcastOperationRequest { */ public ExistsRequest source(String querySource) { this.source = new BytesArray(querySource); - this.sourceUnsafe = false; return this; } @@ -182,19 +170,18 @@ public class ExistsRequest extends BroadcastOperationRequest { * The source to execute. */ public ExistsRequest source(byte[] querySource) { - return source(querySource, 0, querySource.length, false); + return source(querySource, 0, querySource.length); } /** * The source to execute. */ - public ExistsRequest source(byte[] querySource, int offset, int length, boolean unsafe) { - return source(new BytesArray(querySource, offset, length), unsafe); + public ExistsRequest source(byte[] querySource, int offset, int length) { + return source(new BytesArray(querySource, offset, length)); } - public ExistsRequest source(BytesReference querySource, boolean unsafe) { + public ExistsRequest source(BytesReference querySource) { this.source = querySource; - this.sourceUnsafe = unsafe; return this; } @@ -219,7 +206,6 @@ public class ExistsRequest extends BroadcastOperationRequest { minScore = in.readFloat(); routing = in.readOptionalString(); preference = in.readOptionalString(); - sourceUnsafe = false; source = in.readBytesReference(); types = in.readStringArray(); diff --git a/src/main/java/org/elasticsearch/action/exists/ExistsRequestBuilder.java b/src/main/java/org/elasticsearch/action/exists/ExistsRequestBuilder.java index 5214648d86c..7cc7f5983a7 100644 --- a/src/main/java/org/elasticsearch/action/exists/ExistsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/exists/ExistsRequestBuilder.java @@ -91,15 +91,7 @@ public class ExistsRequestBuilder extends BroadcastOperationRequestBuilder private String routing; private String preference; private BytesReference source; - private boolean sourceUnsafe; private String[] fields; private FetchSourceContext fetchSourceContext; @@ -107,19 +106,13 @@ public class ExplainRequest extends SingleShardOperationRequest return source; } - public boolean sourceUnsafe() { - return sourceUnsafe; - } - public ExplainRequest source(QuerySourceBuilder sourceBuilder) { this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - this.sourceUnsafe = false; return this; } - public ExplainRequest source(BytesReference source, boolean unsafe) { + public ExplainRequest source(BytesReference source) { this.source = source; - this.sourceUnsafe = unsafe; return this; } @@ -157,14 +150,6 @@ public class ExplainRequest extends SingleShardOperationRequest return this; } - @Override - protected void beforeLocalFork() { - if (sourceUnsafe) { - source = source.copyBytesArray(); - sourceUnsafe = false; - } - } - @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); @@ -188,7 +173,6 @@ public class ExplainRequest extends SingleShardOperationRequest routing = in.readOptionalString(); preference = in.readOptionalString(); source = in.readBytesReference(); - sourceUnsafe = false; filteringAlias = in.readStringArray(); if (in.readBoolean()) { fields = in.readStringArray(); diff --git a/src/main/java/org/elasticsearch/action/explain/ExplainRequestBuilder.java b/src/main/java/org/elasticsearch/action/explain/ExplainRequestBuilder.java index f5b19137641..6130a223e10 100644 --- a/src/main/java/org/elasticsearch/action/explain/ExplainRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/explain/ExplainRequestBuilder.java @@ -158,8 +158,8 @@ public class ExplainRequestBuilder extends SingleShardOperationRequestBuilder private long ttl = -1; private BytesReference source; - private boolean sourceUnsafe; private OpType opType = OpType.INDEX; private boolean autoGeneratedId = false; @@ -173,7 +172,6 @@ public class IndexRequest extends ShardReplicationOperationRequest this.timestamp = indexRequest.timestamp; this.ttl = indexRequest.ttl; this.source = indexRequest.source; - this.sourceUnsafe = indexRequest.sourceUnsafe; this.opType = indexRequest.opType; this.autoGeneratedId = indexRequest.autoGeneratedId; this.refresh = indexRequest.refresh; @@ -227,15 +225,6 @@ public class IndexRequest extends ShardReplicationOperationRequest return validationException; } - /** - * Before we fork on a local thread, make sure we copy over the bytes if they are unsafe - */ - @Override - public void beforeLocalFork() { - // only fork if copy over if source is unsafe - safeSource(); - } - /** * Sets the content type that will be used when generating a document from user provided objects (like Map). */ @@ -354,14 +343,6 @@ public class IndexRequest extends ShardReplicationOperationRequest return source; } - public BytesReference safeSource() { - if (sourceUnsafe) { - source = source.copyBytesArray(); - sourceUnsafe = false; - } - return source; - } - public Map sourceAsMap() { return XContentHelper.convertToMap(source, false).v2(); } @@ -398,7 +379,6 @@ public class IndexRequest extends ShardReplicationOperationRequest */ public IndexRequest source(String source) { this.source = new BytesArray(source.getBytes(Charsets.UTF_8)); - this.sourceUnsafe = false; return this; } @@ -407,7 +387,6 @@ public class IndexRequest extends ShardReplicationOperationRequest */ public IndexRequest source(XContentBuilder sourceBuilder) { source = sourceBuilder.bytes(); - sourceUnsafe = false; return this; } @@ -455,6 +434,9 @@ public class IndexRequest extends ShardReplicationOperationRequest if (source.length % 2 != 0) { throw new IllegalArgumentException("The number of object passed must be even but was [" + source.length + "]"); } + if (source.length == 2 && source[0] instanceof BytesReference && source[1] instanceof Boolean) { + throw new IllegalArgumentException("you are using the removed method for source with bytes and unsafe flag, the unsafe flag was removed, please just use source(BytesReference)"); + } try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject(); @@ -471,9 +453,8 @@ public class IndexRequest extends ShardReplicationOperationRequest /** * Sets the document to index in bytes form. */ - public IndexRequest source(BytesReference source, boolean unsafe) { + public IndexRequest source(BytesReference source) { this.source = source; - this.sourceUnsafe = unsafe; return this; } @@ -493,20 +474,7 @@ public class IndexRequest extends ShardReplicationOperationRequest * @param length The length of the data */ public IndexRequest source(byte[] source, int offset, int length) { - return source(source, offset, length, false); - } - - /** - * Sets the document to index in bytes form. - * - * @param source The source to index - * @param offset The offset in the byte array - * @param length The length of the data - * @param unsafe Is the byte array safe to be used form a different thread - */ - public IndexRequest source(byte[] source, int offset, int length, boolean unsafe) { this.source = new BytesArray(source, offset, length); - this.sourceUnsafe = unsafe; return this; } @@ -687,7 +655,6 @@ public class IndexRequest extends ShardReplicationOperationRequest timestamp = in.readOptionalString(); ttl = in.readLong(); source = in.readBytesReference(); - sourceUnsafe = false; opType = OpType.fromId(in.readByte()); refresh = in.readBoolean(); diff --git a/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java b/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java index 481d4d434d1..abc993832f5 100644 --- a/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java @@ -78,19 +78,11 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder return this; } - /** - * Sets the source. - */ - public IndexRequestBuilder setSource(BytesReference source, boolean unsafe) { - request.source(source, unsafe); - return this; - } - /** * Sets the source. */ public IndexRequestBuilder setSource(BytesReference source) { - request.source(source, false); + request.source(source); return this; } @@ -154,19 +146,6 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder return this; } - /** - * Sets the document to index in bytes form. - * - * @param source The source to index - * @param offset The offset in the byte array - * @param length The length of the data - * @param unsafe Is the byte array safe to be used form a different thread - */ - public IndexRequestBuilder setSource(byte[] source, int offset, int length, boolean unsafe) { - request.source(source, offset, length, unsafe); - return this; - } - /** * Constructs a simple document with a field and a value. */ diff --git a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java index b6f9bd60199..34a7487a9ec 100644 --- a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java +++ b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java @@ -85,7 +85,6 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi protected void doExecute(final IndexRequest request, final ActionListener listener) { // if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) { - request.beforeLocalFork(); // we fork on another thread... CreateIndexRequest createIndexRequest = new CreateIndexRequest(request); createIndexRequest.index(request.index()); createIndexRequest.mapping(request.type()); diff --git a/src/main/java/org/elasticsearch/action/indexedscripts/put/PutIndexedScriptRequest.java b/src/main/java/org/elasticsearch/action/indexedscripts/put/PutIndexedScriptRequest.java index 20fa0da27ed..86de6c46291 100644 --- a/src/main/java/org/elasticsearch/action/indexedscripts/put/PutIndexedScriptRequest.java +++ b/src/main/java/org/elasticsearch/action/indexedscripts/put/PutIndexedScriptRequest.java @@ -64,7 +64,6 @@ public class PutIndexedScriptRequest extends ActionRequest sourceAsMap() { return XContentHelper.convertToMap(source, false).v2(); } @@ -215,7 +206,6 @@ public class PutIndexedScriptRequest extends ActionRequestNote: the number of objects passed to this method must be an even number. diff --git a/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java b/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java index 86d9c4bc1d8..202383dbf3c 100644 --- a/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java +++ b/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java @@ -22,7 +22,6 @@ package org.elasticsearch.action.mlt; import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.Version; import org.elasticsearch.action.*; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchType; @@ -33,7 +32,6 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.search.Scroll; @@ -86,7 +84,6 @@ public class MoreLikeThisRequest extends ActionRequest impl private Scroll searchScroll; private BytesReference searchSource; - private boolean searchSourceUnsafe; MoreLikeThisRequest() { } @@ -401,20 +398,12 @@ public class MoreLikeThisRequest extends ActionRequest impl return this.include; } - void beforeLocalFork() { - if (searchSourceUnsafe) { - searchSource = searchSource.copyBytesArray(); - searchSourceUnsafe = false; - } - } - /** * An optional search source request allowing to control the search request for the * more like this documents. */ public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) { this.searchSource = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - this.searchSourceUnsafe = false; return this; } @@ -424,7 +413,6 @@ public class MoreLikeThisRequest extends ActionRequest impl */ public MoreLikeThisRequest searchSource(String searchSource) { this.searchSource = new BytesArray(searchSource); - this.searchSourceUnsafe = false; return this; } @@ -440,7 +428,6 @@ public class MoreLikeThisRequest extends ActionRequest impl public MoreLikeThisRequest searchSource(XContentBuilder builder) { this.searchSource = builder.bytes(); - this.searchSourceUnsafe = false; return this; } @@ -449,24 +436,23 @@ public class MoreLikeThisRequest extends ActionRequest impl * more like this documents. */ public MoreLikeThisRequest searchSource(byte[] searchSource) { - return searchSource(searchSource, 0, searchSource.length, false); + return searchSource(searchSource, 0, searchSource.length); } /** * An optional search source request allowing to control the search request for the * more like this documents. */ - public MoreLikeThisRequest searchSource(byte[] searchSource, int offset, int length, boolean unsafe) { - return searchSource(new BytesArray(searchSource, offset, length), unsafe); + public MoreLikeThisRequest searchSource(byte[] searchSource, int offset, int length) { + return searchSource(new BytesArray(searchSource, offset, length)); } /** * An optional search source request allowing to control the search request for the * more like this documents. */ - public MoreLikeThisRequest searchSource(BytesReference searchSource, boolean unsafe) { + public MoreLikeThisRequest searchSource(BytesReference searchSource) { this.searchSource = searchSource; - this.searchSourceUnsafe = unsafe; return this; } @@ -478,10 +464,6 @@ public class MoreLikeThisRequest extends ActionRequest impl return this.searchSource; } - public boolean searchSourceUnsafe() { - return searchSourceUnsafe; - } - /** * The search type of the mlt search query. */ @@ -656,7 +638,6 @@ public class MoreLikeThisRequest extends ActionRequest impl searchScroll = readScroll(in); } - searchSourceUnsafe = false; searchSource = in.readBytesReference(); searchSize = in.readVInt(); diff --git a/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java b/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java index 7b835fe3fea..6457d42084a 100644 --- a/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java +++ b/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java @@ -132,7 +132,6 @@ public class TransportMoreLikeThisAction extends HandledTransportAction() { @Override public void onResponse(GetResponse getResponse) { @@ -221,7 +220,7 @@ public class TransportMoreLikeThisAction extends HandledTransportAction() { diff --git a/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java b/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java index 2ac54c0898b..1e4438ce7bd 100644 --- a/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java +++ b/src/main/java/org/elasticsearch/action/percolate/MultiPercolateRequest.java @@ -81,14 +81,14 @@ public class MultiPercolateRequest extends ActionRequest /** * Embeds a percolate request which request body is defined as raw bytes to this multi percolate request */ - public MultiPercolateRequest add(byte[] data, int from, int length, boolean contentUnsafe) throws Exception { - return add(new BytesArray(data, from, length), contentUnsafe, true); + public MultiPercolateRequest add(byte[] data, int from, int length) throws Exception { + return add(new BytesArray(data, from, length), true); } /** * Embeds a percolate request which request body is defined as raw bytes to this multi percolate request */ - public MultiPercolateRequest add(BytesReference data, boolean contentUnsafe, boolean allowExplicitIndex) throws Exception { + public MultiPercolateRequest add(BytesReference data, boolean allowExplicitIndex) throws Exception { XContent xContent = XContentFactory.xContent(data); int from = 0; int length = data.length(); @@ -153,7 +153,7 @@ public class MultiPercolateRequest extends ActionRequest break; } - percolateRequest.source(data.slice(from, nextMarker - from), contentUnsafe); + percolateRequest.source(data.slice(from, nextMarker - from)); // move pointers from = nextMarker + 1; diff --git a/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java b/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java index 305dafa0c76..c60c8452ff1 100644 --- a/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java +++ b/src/main/java/org/elasticsearch/action/percolate/PercolateRequest.java @@ -54,7 +54,6 @@ public class PercolateRequest extends BroadcastOperationRequest implem return this; } - public MultiSearchRequest add(byte[] data, int from, int length, boolean contentUnsafe, + public MultiSearchRequest add(byte[] data, int from, int length, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType) throws Exception { - return add(new BytesArray(data, from, length), contentUnsafe, indices, types, searchType, null, IndicesOptions.strictExpandOpenAndForbidClosed(), true); + return add(new BytesArray(data, from, length), indices, types, searchType, null, IndicesOptions.strictExpandOpenAndForbidClosed(), true); } - public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, IndicesOptions indicesOptions) throws Exception { - return add(data, contentUnsafe, indices, types, searchType, null, indicesOptions, true); + public MultiSearchRequest add(BytesReference data, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, IndicesOptions indicesOptions) throws Exception { + return add(data, indices, types, searchType, null, indicesOptions, true); } - public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, @Nullable String routing, IndicesOptions indicesOptions, boolean allowExplicitIndex) throws Exception { + public MultiSearchRequest add(BytesReference data, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, @Nullable String routing, IndicesOptions indicesOptions, boolean allowExplicitIndex) throws Exception { XContent xContent = XContentFactory.xContent(data); int from = 0; int length = data.length(); @@ -196,7 +196,7 @@ public class MultiSearchRequest extends ActionRequest implem break; } - searchRequest.source(data.slice(from, nextMarker - from), contentUnsafe); + searchRequest.source(data.slice(from, nextMarker - from)); // move pointers from = nextMarker + 1; diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/src/main/java/org/elasticsearch/action/search/SearchRequest.java index 58e0cdfc0e6..1c16f3a8b35 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -70,16 +70,13 @@ public class SearchRequest extends ActionRequest implements Indic private String preference; private BytesReference templateSource; - private boolean templateSourceUnsafe; private String templateName; private ScriptService.ScriptType templateType; private Map templateParams = Collections.emptyMap(); private BytesReference source; - private boolean sourceUnsafe; private BytesReference extraSource; - private boolean extraSourceUnsafe; private Boolean queryCache; private Scroll scroll; @@ -104,14 +101,11 @@ public class SearchRequest extends ActionRequest implements Indic this.routing = searchRequest.routing; this.preference = searchRequest.preference; this.templateSource = searchRequest.templateSource; - this.templateSourceUnsafe = searchRequest.templateSourceUnsafe; this.templateName = searchRequest.templateName; this.templateType = searchRequest.templateType; this.templateParams = searchRequest.templateParams; this.source = searchRequest.source; - this.sourceUnsafe = searchRequest.sourceUnsafe; this.extraSource = searchRequest.extraSource; - this.extraSourceUnsafe = searchRequest.extraSourceUnsafe; this.queryCache = searchRequest.queryCache; this.scroll = searchRequest.scroll; this.types = searchRequest.types; @@ -152,23 +146,6 @@ public class SearchRequest extends ActionRequest implements Indic return validationException; } - public void beforeStart() { - // we always copy over if needed, the reason is that a request might fail while being search remotely - // and then we need to keep the buffer around - if (source != null && sourceUnsafe) { - source = source.copyBytesArray(); - sourceUnsafe = false; - } - if (extraSource != null && extraSourceUnsafe) { - extraSource = extraSource.copyBytesArray(); - extraSourceUnsafe = false; - } - if (templateSource != null && templateSourceUnsafe) { - templateSource = templateSource.copyBytesArray(); - templateSourceUnsafe = false; - } - } - /** * Sets the indices the search will be executed on. */ @@ -273,7 +250,6 @@ public class SearchRequest extends ActionRequest implements Indic */ public SearchRequest source(SearchSourceBuilder sourceBuilder) { this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - this.sourceUnsafe = false; return this; } @@ -283,7 +259,6 @@ public class SearchRequest extends ActionRequest implements Indic */ public SearchRequest source(String source) { this.source = new BytesArray(source); - this.sourceUnsafe = false; return this; } @@ -302,7 +277,6 @@ public class SearchRequest extends ActionRequest implements Indic public SearchRequest source(XContentBuilder builder) { this.source = builder.bytes(); - this.sourceUnsafe = false; return this; } @@ -310,7 +284,7 @@ public class SearchRequest extends ActionRequest implements Indic * The search source to execute. */ public SearchRequest source(byte[] source) { - return source(source, 0, source.length, false); + return source(source, 0, source.length); } @@ -318,22 +292,14 @@ public class SearchRequest extends ActionRequest implements Indic * The search source to execute. */ public SearchRequest source(byte[] source, int offset, int length) { - return source(source, offset, length, false); + return source(new BytesArray(source, offset, length)); } /** * The search source to execute. */ - public SearchRequest source(byte[] source, int offset, int length, boolean unsafe) { - return source(new BytesArray(source, offset, length), unsafe); - } - - /** - * The search source to execute. - */ - public SearchRequest source(BytesReference source, boolean unsafe) { + public SearchRequest source(BytesReference source) { this.source = source; - this.sourceUnsafe = unsafe; return this; } @@ -360,7 +326,6 @@ public class SearchRequest extends ActionRequest implements Indic return this; } this.extraSource = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - this.extraSourceUnsafe = false; return this; } @@ -376,7 +341,6 @@ public class SearchRequest extends ActionRequest implements Indic public SearchRequest extraSource(XContentBuilder builder) { this.extraSource = builder.bytes(); - this.extraSourceUnsafe = false; return this; } @@ -385,7 +349,6 @@ public class SearchRequest extends ActionRequest implements Indic */ public SearchRequest extraSource(String source) { this.extraSource = new BytesArray(source); - this.extraSourceUnsafe = false; return this; } @@ -393,38 +356,29 @@ public class SearchRequest extends ActionRequest implements Indic * Allows to provide additional source that will be used as well. */ public SearchRequest extraSource(byte[] source) { - return extraSource(source, 0, source.length, false); + return extraSource(source, 0, source.length); } /** * Allows to provide additional source that will be used as well. */ public SearchRequest extraSource(byte[] source, int offset, int length) { - return extraSource(source, offset, length, false); + return extraSource(new BytesArray(source, offset, length)); } /** * Allows to provide additional source that will be used as well. */ - public SearchRequest extraSource(byte[] source, int offset, int length, boolean unsafe) { - return extraSource(new BytesArray(source, offset, length), unsafe); - } - - /** - * Allows to provide additional source that will be used as well. - */ - public SearchRequest extraSource(BytesReference source, boolean unsafe) { + public SearchRequest extraSource(BytesReference source) { this.extraSource = source; - this.extraSourceUnsafe = unsafe; return this; } /** * Allows to provide template as source. */ - public SearchRequest templateSource(BytesReference template, boolean unsafe) { + public SearchRequest templateSource(BytesReference template) { this.templateSource = template; - this.templateSourceUnsafe = unsafe; return this; } @@ -433,7 +387,6 @@ public class SearchRequest extends ActionRequest implements Indic */ public SearchRequest templateSource(String template) { this.templateSource = new BytesArray(template); - this.templateSourceUnsafe = false; return this; } @@ -558,16 +511,12 @@ public class SearchRequest extends ActionRequest implements Indic scroll = readScroll(in); } - sourceUnsafe = false; source = in.readBytesReference(); - - extraSourceUnsafe = false; extraSource = in.readBytesReference(); types = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - templateSourceUnsafe = false; templateSource = in.readBytesReference(); templateName = in.readOptionalString(); templateType = ScriptService.ScriptType.readFrom(in); diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java b/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java index 9b8e3c37ec4..59d6db804b0 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java @@ -850,21 +850,10 @@ public class SearchRequestBuilder extends ActionRequestBuilder *

The request requires the suggest query source to be set either using - * {@link #suggest(org.elasticsearch.common.bytes.BytesReference)} / {@link #suggest(org.elasticsearch.common.bytes.BytesReference, boolean)} + * {@link #suggest(org.elasticsearch.common.bytes.BytesReference)} / {@link #suggest(org.elasticsearch.common.bytes.BytesReference)} * or by using {@link #suggest(org.elasticsearch.search.suggest.SuggestBuilder)} * (Best created using the {link @org.elasticsearch.search.suggest.SuggestBuilders)}). * @@ -57,7 +57,6 @@ public final class SuggestRequest extends BroadcastOperationRequest() { diff --git a/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java b/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java index ae1df8b3862..df99d045177 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java @@ -387,7 +387,6 @@ public abstract class TransportShardReplicationOperationAction { return searchRequest.validate(); } - @Override - protected void beforeStart() { - searchRequest.beforeStart(); - } - @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); diff --git a/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java b/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java index 4a55112ba80..d06d0957dd6 100644 --- a/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java +++ b/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java @@ -112,12 +112,6 @@ public class NettyHttpRequest extends HttpRequest { return content.length() > 0; } - @Override - public boolean contentUnsafe() { - // Netty http decoder always copies over the http content - return false; - } - @Override public BytesReference content() { return content; diff --git a/src/main/java/org/elasticsearch/rest/RestRequest.java b/src/main/java/org/elasticsearch/rest/RestRequest.java index 7f94a6ca045..a908e5c55a7 100644 --- a/src/main/java/org/elasticsearch/rest/RestRequest.java +++ b/src/main/java/org/elasticsearch/rest/RestRequest.java @@ -66,11 +66,6 @@ public abstract class RestRequest extends ContextHolder implements ToXContent.Pa public abstract boolean hasContent(); - /** - * Is the byte array content safe or unsafe for usage on other threads - */ - public abstract boolean contentUnsafe(); - public abstract BytesReference content(); public abstract String header(String name); diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java index 93a2a79d241..d9ef297c83d 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java @@ -60,7 +60,7 @@ public class RestValidateQueryAction extends BaseRestHandler { validateQueryRequest.listenerThreaded(false); validateQueryRequest.indicesOptions(IndicesOptions.fromRequest(request, validateQueryRequest.indicesOptions())); if (request.hasContent()) { - validateQueryRequest.source(request.content(), request.contentUnsafe()); + validateQueryRequest.source(request.content()); } else { String source = request.param("source"); if (source != null) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/warmer/put/RestPutWarmerAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/warmer/put/RestPutWarmerAction.java index 66c8266bc35..9a802f1bf3d 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/warmer/put/RestPutWarmerAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/warmer/put/RestPutWarmerAction.java @@ -63,7 +63,7 @@ public class RestPutWarmerAction extends BaseRestHandler { SearchRequest searchRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index"))) .types(Strings.splitStringByCommaToArray(request.param("type"))) .queryCache(request.paramAsBoolean("query_cache", null)) - .source(request.content(), request.contentUnsafe()); + .source(request.content()); searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions())); putWarmerRequest.searchRequest(searchRequest); putWarmerRequest.timeout(request.paramAsTime("timeout", putWarmerRequest.timeout())); diff --git a/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java b/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java index 2c02892662c..9578e078270 100644 --- a/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java +++ b/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java @@ -82,7 +82,7 @@ public class RestBulkAction extends BaseRestHandler { } bulkRequest.timeout(request.paramAsTime("timeout", BulkShardRequest.DEFAULT_TIMEOUT)); bulkRequest.refresh(request.paramAsBoolean("refresh", bulkRequest.refresh())); - bulkRequest.add(request.content(), request.contentUnsafe(), defaultIndex, defaultType, defaultRouting, null, allowExplicitIndex); + bulkRequest.add(request.content(), defaultIndex, defaultType, defaultRouting, null, allowExplicitIndex); client.bulk(bulkRequest, new RestBuilderListener(channel) { @Override diff --git a/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java b/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java index 58ac7ee730e..82e11f75bea 100644 --- a/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java +++ b/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java @@ -61,7 +61,7 @@ public class RestCountAction extends BaseRestHandler { countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions())); countRequest.listenerThreaded(false); if (request.hasContent()) { - countRequest.source(request.content(), request.contentUnsafe()); + countRequest.source(request.content()); } else { String source = request.param("source"); if (source != null) { diff --git a/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java b/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java index 9c0718616b4..ee9935d103a 100644 --- a/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java @@ -55,7 +55,7 @@ public class RestDeleteByQueryAction extends BaseRestHandler { DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(Strings.splitStringByCommaToArray(request.param("index"))); deleteByQueryRequest.listenerThreaded(false); if (request.hasContent()) { - deleteByQueryRequest.source(request.content(), request.contentUnsafe()); + deleteByQueryRequest.source(request.content()); } else { String source = request.param("source"); if (source != null) { diff --git a/src/main/java/org/elasticsearch/rest/action/exists/RestExistsAction.java b/src/main/java/org/elasticsearch/rest/action/exists/RestExistsAction.java index 7741da25372..a10143c87b1 100644 --- a/src/main/java/org/elasticsearch/rest/action/exists/RestExistsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/exists/RestExistsAction.java @@ -50,7 +50,7 @@ public class RestExistsAction extends BaseRestHandler { existsRequest.indicesOptions(IndicesOptions.fromRequest(request, existsRequest.indicesOptions())); existsRequest.listenerThreaded(false); if (request.hasContent()) { - existsRequest.source(request.content(), request.contentUnsafe()); + existsRequest.source(request.content()); } else { String source = request.param("source"); if (source != null) { diff --git a/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java b/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java index 0ce02a36f41..708d1a4ad44 100644 --- a/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java +++ b/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java @@ -66,9 +66,9 @@ public class RestExplainAction extends BaseRestHandler { String sourceString = request.param("source"); String queryString = request.param("q"); if (request.hasContent()) { - explainRequest.source(request.content(), request.contentUnsafe()); + explainRequest.source(request.content()); } else if (sourceString != null) { - explainRequest.source(new BytesArray(request.param("source")), false); + explainRequest.source(new BytesArray(request.param("source"))); } else if (queryString != null) { QueryStringQueryBuilder queryStringBuilder = QueryBuilders.queryStringQuery(queryString); queryStringBuilder.defaultField(request.param("df")); diff --git a/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java b/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java index b30d9d9bb67..e196d954a7c 100644 --- a/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java @@ -79,7 +79,7 @@ public class RestIndexAction extends BaseRestHandler { if (request.hasParam("ttl")) { indexRequest.ttl(request.paramAsTime("ttl", null).millis()); } - indexRequest.source(request.content(), request.contentUnsafe()); + indexRequest.source(request.content()); indexRequest.timeout(request.paramAsTime("timeout", IndexRequest.DEFAULT_TIMEOUT)); indexRequest.refresh(request.paramAsBoolean("refresh", indexRequest.refresh())); indexRequest.version(RestActions.parseVersion(request)); diff --git a/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java b/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java index b716e3881e7..a9d60e02aa5 100644 --- a/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java +++ b/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java @@ -77,7 +77,7 @@ public class RestMoreLikeThisAction extends BaseRestHandler { mltRequest.searchScroll(new Scroll(parseTimeValue(searchScroll, null))); } if (request.hasContent()) { - mltRequest.searchSource(request.content(), request.contentUnsafe()); + mltRequest.searchSource(request.content()); } else { String searchSource = request.param("search_source"); if (searchSource != null) { diff --git a/src/main/java/org/elasticsearch/rest/action/percolate/RestMultiPercolateAction.java b/src/main/java/org/elasticsearch/rest/action/percolate/RestMultiPercolateAction.java index c532c147aea..d9a1d9f4cb4 100644 --- a/src/main/java/org/elasticsearch/rest/action/percolate/RestMultiPercolateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/percolate/RestMultiPercolateAction.java @@ -59,7 +59,7 @@ public class RestMultiPercolateAction extends BaseRestHandler { multiPercolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, multiPercolateRequest.indicesOptions())); multiPercolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index"))); multiPercolateRequest.documentType(restRequest.param("type")); - multiPercolateRequest.add(RestActions.getRestContent(restRequest), restRequest.contentUnsafe(), allowExplicitIndex); + multiPercolateRequest.add(RestActions.getRestContent(restRequest), allowExplicitIndex); client.multiPercolate(multiPercolateRequest, new RestToXContentListener(restChannel)); } diff --git a/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java b/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java index 0736ec5d742..fb609d3e14a 100644 --- a/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java @@ -63,7 +63,7 @@ public class RestPercolateAction extends BaseRestHandler { percolateRequest.documentType(restRequest.param("type")); percolateRequest.routing(restRequest.param("routing")); percolateRequest.preference(restRequest.param("preference")); - percolateRequest.source(RestActions.getRestContent(restRequest), restRequest.contentUnsafe()); + percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); executePercolate(percolateRequest, restChannel, client); @@ -87,7 +87,7 @@ public class RestPercolateAction extends BaseRestHandler { percolateRequest.getRequest(getRequest); percolateRequest.routing(restRequest.param("percolate_routing")); percolateRequest.preference(restRequest.param("percolate_preference")); - percolateRequest.source(RestActions.getRestContent(restRequest), restRequest.contentUnsafe()); + percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); executePercolate(percolateRequest, restChannel, client); diff --git a/src/main/java/org/elasticsearch/rest/action/script/RestPutIndexedScriptAction.java b/src/main/java/org/elasticsearch/rest/action/script/RestPutIndexedScriptAction.java index 6a4ce195b7d..aab5774af9a 100644 --- a/src/main/java/org/elasticsearch/rest/action/script/RestPutIndexedScriptAction.java +++ b/src/main/java/org/elasticsearch/rest/action/script/RestPutIndexedScriptAction.java @@ -79,7 +79,7 @@ public class RestPutIndexedScriptAction extends BaseRestHandler { PutIndexedScriptRequest putRequest = new PutIndexedScriptRequest(getScriptLang(request), request.param("id")).listenerThreaded(false); putRequest.version(request.paramAsLong("version", putRequest.version())); putRequest.versionType(VersionType.fromString(request.param("version_type"), putRequest.versionType())); - putRequest.source(request.content(), request.contentUnsafe()); + putRequest.source(request.content()); String sOpType = request.param("op_type"); if (sOpType != null) { try { diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java index e22290c6c24..92c0ba9b217 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java @@ -61,7 +61,7 @@ public class RestMultiSearchAction extends BaseRestHandler { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String[] types = Strings.splitStringByCommaToArray(request.param("type")); IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, multiSearchRequest.indicesOptions()); - multiSearchRequest.add(RestActions.getRestContent(request), request.contentUnsafe(), indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex); + multiSearchRequest.add(RestActions.getRestContent(request), indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex); client.multiSearch(multiSearchRequest, new RestToXContentListener(channel)); } diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 9c4052334db..a0e04a1af06 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -89,9 +89,9 @@ public class RestSearchAction extends BaseRestHandler { boolean isTemplateRequest = request.path().endsWith("/template"); if (request.hasContent()) { if (isTemplateRequest) { - searchRequest.templateSource(request.content(), request.contentUnsafe()); + searchRequest.templateSource(request.content()); } else { - searchRequest.source(request.content(), request.contentUnsafe()); + searchRequest.source(request.content()); } } else { String source = request.param("source"); diff --git a/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java b/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java index 2a226222fd6..28b30efd893 100644 --- a/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java +++ b/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java @@ -61,7 +61,7 @@ public class RestSuggestAction extends BaseRestHandler { suggestRequest.indicesOptions(IndicesOptions.fromRequest(request, suggestRequest.indicesOptions())); suggestRequest.listenerThreaded(false); if (request.hasContent()) { - suggestRequest.suggest(request.content(), request.contentUnsafe()); + suggestRequest.suggest(request.content()); } else { String source = request.param("source"); if (source != null) { diff --git a/src/main/java/org/elasticsearch/script/ScriptService.java b/src/main/java/org/elasticsearch/script/ScriptService.java index 53834aa8a60..1ed9bec8497 100644 --- a/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/src/main/java/org/elasticsearch/script/ScriptService.java @@ -336,11 +336,11 @@ public class ScriptService extends AbstractComponent implements Closeable { public void putScriptToIndex(PutIndexedScriptRequest request, ActionListener listener) { String scriptLang = validateScriptLanguage(request.scriptLang()); //verify that the script compiles - validate(request.safeSource(), scriptLang); + validate(request.source(), scriptLang); IndexRequest indexRequest = new IndexRequest(request).index(SCRIPT_INDEX).type(scriptLang).id(request.id()) .version(request.version()).versionType(request.versionType()) - .source(request.safeSource(), true).opType(request.opType()).refresh(true); //Always refresh after indexing a template + .source(request.source()).opType(request.opType()).refresh(true); //Always refresh after indexing a template client.index(indexRequest, listener); } diff --git a/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationTests.java b/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationTests.java index 8d8e9e996f3..12dc753b315 100644 --- a/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationTests.java +++ b/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationTests.java @@ -33,7 +33,7 @@ public class BulkIntegrationTests extends ElasticsearchIntegrationTest { public void testBulkIndexCreatesMapping() throws Exception { String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/bulk-log.json"); BulkRequestBuilder bulkBuilder = new BulkRequestBuilder(client()); - bulkBuilder.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null); + bulkBuilder.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null); bulkBuilder.get(); assertBusy(new Runnable() { @Override diff --git a/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java index d92610ab3eb..3e1e762b45c 100644 --- a/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java +++ b/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java @@ -48,7 +48,7 @@ public class BulkRequestTests extends ElasticsearchTestCase { bulkAction = Strings.replace(bulkAction, "\r\n", "\n"); } BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null); + bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null); assertThat(bulkRequest.numberOfActions(), equalTo(3)); assertThat(((IndexRequest) bulkRequest.requests().get(0)).source().toBytes(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }").toBytes())); assertThat(bulkRequest.requests().get(1), instanceOf(DeleteRequest.class)); @@ -59,7 +59,7 @@ public class BulkRequestTests extends ElasticsearchTestCase { public void testSimpleBulk2() throws Exception { String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk2.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null); + bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null); assertThat(bulkRequest.numberOfActions(), equalTo(3)); } @@ -67,7 +67,7 @@ public class BulkRequestTests extends ElasticsearchTestCase { public void testSimpleBulk3() throws Exception { String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk3.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null); + bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null); assertThat(bulkRequest.numberOfActions(), equalTo(3)); } @@ -75,7 +75,7 @@ public class BulkRequestTests extends ElasticsearchTestCase { public void testSimpleBulk4() throws Exception { String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk4.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null); + bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null); assertThat(bulkRequest.numberOfActions(), equalTo(4)); assertThat(((UpdateRequest) bulkRequest.requests().get(0)).id(), equalTo("1")); assertThat(((UpdateRequest) bulkRequest.requests().get(0)).retryOnConflict(), equalTo(2)); @@ -94,14 +94,14 @@ public class BulkRequestTests extends ElasticsearchTestCase { public void testBulkAllowExplicitIndex() throws Exception { String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json"); try { - new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), true, null, null, false); + new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), null, null, false); fail(); } catch (Exception e) { } bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk5.json"); - new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), true, "test", null, false); + new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), "test", null, false); } @Test diff --git a/src/test/java/org/elasticsearch/action/mlt/MoreLikeThisRequestTests.java b/src/test/java/org/elasticsearch/action/mlt/MoreLikeThisRequestTests.java index f1436f0dea1..99a01de5047 100644 --- a/src/test/java/org/elasticsearch/action/mlt/MoreLikeThisRequestTests.java +++ b/src/test/java/org/elasticsearch/action/mlt/MoreLikeThisRequestTests.java @@ -134,7 +134,6 @@ public class MoreLikeThisRequestTests extends ElasticsearchTestCase { assertThat(mltRequest2.searchSource().length(), equalTo(0)); } else { assertThat(mltRequest2.searchSource().length(), equalTo(mltRequest.searchSource().length())); - assertThat(mltRequest2.searchSourceUnsafe(), equalTo(mltRequest.searchSourceUnsafe())); } if (mltRequest.stopWords() != null && mltRequest.stopWords().length > 0) { diff --git a/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java b/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java index 975b4b91a67..26af18c90d0 100644 --- a/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java +++ b/src/test/java/org/elasticsearch/action/percolate/MultiPercolatorRequestTests.java @@ -36,7 +36,7 @@ public class MultiPercolatorRequestTests extends ElasticsearchTestCase { @Test public void testParseBulkRequests() throws Exception { byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate1.json"); - MultiPercolateRequest request = new MultiPercolateRequest().add(data, 0, data.length, false); + MultiPercolateRequest request = new MultiPercolateRequest().add(data, 0, data.length); assertThat(request.requests().size(), equalTo(6)); PercolateRequest percolateRequest = request.requests().get(0); @@ -123,7 +123,7 @@ public class MultiPercolatorRequestTests extends ElasticsearchTestCase { byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate2.json"); MultiPercolateRequest request = new MultiPercolateRequest(); request.indices("my-index1").documentType("my-type1").indicesOptions(IndicesOptions.lenientExpandOpen()); - request.add(data, 0, data.length, false); + request.add(data, 0, data.length); assertThat(request.requests().size(), equalTo(3)); PercolateRequest percolateRequest = request.requests().get(0); diff --git a/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java b/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java index 4ddb393d790..d4d82ede283 100644 --- a/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java +++ b/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java @@ -34,7 +34,7 @@ public class MultiSearchRequestTests extends ElasticsearchTestCase { @Test public void simpleAdd() throws Exception { byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch1.json"); - MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, false, null, null, null); + MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, null, null, null); assertThat(request.requests().size(), equalTo(5)); assertThat(request.requests().get(0).indices()[0], equalTo("test")); assertThat(request.requests().get(0).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed()))); @@ -54,7 +54,7 @@ public class MultiSearchRequestTests extends ElasticsearchTestCase { @Test public void simpleAdd2() throws Exception { byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch2.json"); - MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, false, null, null, null); + MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, null, null, null); assertThat(request.requests().size(), equalTo(5)); assertThat(request.requests().get(0).indices()[0], equalTo("test")); assertThat(request.requests().get(0).types().length, equalTo(0)); @@ -72,7 +72,7 @@ public class MultiSearchRequestTests extends ElasticsearchTestCase { @Test public void simpleAdd3() throws Exception { byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch3.json"); - MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, false, null, null, null); + MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, null, null, null); assertThat(request.requests().size(), equalTo(4)); assertThat(request.requests().get(0).indices()[0], equalTo("test0")); assertThat(request.requests().get(0).indices()[1], equalTo("test1")); diff --git a/src/test/java/org/elasticsearch/document/BulkTests.java b/src/test/java/org/elasticsearch/document/BulkTests.java index aa1a63c1be4..f49914606dd 100644 --- a/src/test/java/org/elasticsearch/document/BulkTests.java +++ b/src/test/java/org/elasticsearch/document/BulkTests.java @@ -430,8 +430,8 @@ public class BulkTests extends ElasticsearchIntegrationTest { byte[] addChild = new BytesArray("{ \"update\" : { \"_index\" : \"test\", \"_type\" : \"child\", \"_id\" : \"child1\", \"parent\" : \"parent1\"}}\n" + "{\"doc\" : { \"field1\" : \"value1\"}, \"doc_as_upsert\" : \"true\"}\n").array(); - builder.add(addParent, 0, addParent.length, false); - builder.add(addChild, 0, addChild.length, false); + builder.add(addParent, 0, addParent.length); + builder.add(addChild, 0, addChild.length); BulkResponse bulkResponse = builder.get(); assertThat(bulkResponse.getItems().length, equalTo(2)); @@ -467,8 +467,8 @@ public class BulkTests extends ElasticsearchIntegrationTest { byte[] addChild = new BytesArray("{\"update\" : { \"_id\" : \"child1\", \"_type\" : \"child\", \"_index\" : \"test\", \"parent\" : \"parent1\"} }\n" + "{ \"script\" : \"ctx._source.field2 = 'value2'\", \"upsert\" : {\"field1\" : \"value1\"}}\n").array(); - builder.add(addParent, 0, addParent.length, false); - builder.add(addChild, 0, addChild.length, false); + builder.add(addParent, 0, addParent.length); + builder.add(addChild, 0, addChild.length); BulkResponse bulkResponse = builder.get(); assertThat(bulkResponse.getItems().length, equalTo(2)); @@ -505,10 +505,10 @@ public class BulkTests extends ElasticsearchIntegrationTest { "{\"index\" : { \"_id\" : \"child2\", \"_type\" : \"child\", \"_index\" : \"test\"} }\n" + "{ \"field1\" : \"value1\"}\n") .array(); - builder.add(addParent, 0, addParent.length, false); - builder.add(addChildOK, 0, addChildOK.length, false); - builder.add(addChildMissingRouting, 0, addChildMissingRouting.length, false); - builder.add(addChildOK, 0, addChildOK.length, false); + builder.add(addParent, 0, addParent.length); + builder.add(addChildOK, 0, addChildOK.length); + builder.add(addChildMissingRouting, 0, addChildMissingRouting.length); + builder.add(addChildOK, 0, addChildOK.length); BulkResponse bulkResponse = builder.get(); assertThat(bulkResponse.getItems().length, equalTo(4)); @@ -578,7 +578,7 @@ public class BulkTests extends ElasticsearchIntegrationTest { "{\"index\": {\"_id\": \"2\"}}\n" + "{\"name\": \"Good\", \"last_modified\" : \"2013-04-05\"}\n"; - BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), false, "test", "type").setRefresh(true).get(); + BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), "test", "type").setRefresh(true).get(); assertThat(bulkResponse.getItems().length, is(2)); assertThat(bulkResponse.getItems()[0].isFailed(), is(true)); assertThat(bulkResponse.getItems()[1].isFailed(), is(false)); @@ -605,7 +605,7 @@ public class BulkTests extends ElasticsearchIntegrationTest { "{\"index\": { \"_id\" : \"24000\" } }\n" + "{\"name\": \"Good\", \"my_routing\" : \"48000\"}\n"; - BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), false, "test", "type").setRefresh(true).get(); + BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), "test", "type").setRefresh(true).get(); assertThat(bulkResponse.getItems().length, is(2)); assertThat(bulkResponse.getItems()[0].isFailed(), is(true)); assertThat(bulkResponse.getItems()[1].isFailed(), is(false)); @@ -632,7 +632,7 @@ public class BulkTests extends ElasticsearchIntegrationTest { "{\"index\": {} }\n" + "{\"name\": \"Good\", \"my_id\" : \"48\"}\n"; - BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), false, "test", "type").setRefresh(true).get(); + BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), "test", "type").setRefresh(true).get(); assertThat(bulkResponse.getItems().length, is(2)); assertThat(bulkResponse.getItems()[0].isFailed(), is(true)); assertThat(bulkResponse.getItems()[1].isFailed(), is(false)); diff --git a/src/test/java/org/elasticsearch/index/IndexRequestBuilderTests.java b/src/test/java/org/elasticsearch/index/IndexRequestBuilderTests.java index 50523fcd5cd..e77242cfea8 100644 --- a/src/test/java/org/elasticsearch/index/IndexRequestBuilderTests.java +++ b/src/test/java/org/elasticsearch/index/IndexRequestBuilderTests.java @@ -44,7 +44,7 @@ public class IndexRequestBuilderTests extends ElasticsearchIntegrationTest { client().prepareIndex("test", "test").setSource((Object)"test_field", (Object)"foobar"), client().prepareIndex("test", "test").setSource("{\"test_field\" : \"foobar\"}"), client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}")), - client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), randomBoolean()), + client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}")), client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}").toBytes()), client().prepareIndex("test", "test").setSource(map) }; diff --git a/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java b/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java index aed0d1854a5..0d8b8909d21 100644 --- a/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java +++ b/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java @@ -169,7 +169,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest { String query = "{ \"template\" : { \"query\": {\"match_{{template}}\": {} } }, \"params\" : { \"template\":\"all\" } }"; BytesReference bytesRef = new BytesArray(query); - searchRequest.templateSource(bytesRef, false); + searchRequest.templateSource(bytesRef); SearchResponse searchResponse = client().search(searchRequest).get(); assertHitCount(searchResponse, 2); @@ -183,7 +183,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest { try { String query = "{ \"template\" : { \"query\": {\"match_all\": {}}, \"size\" : \"{{my_size}}\" } }"; BytesReference bytesRef = new BytesArray(query); - searchRequest.templateSource(bytesRef, false); + searchRequest.templateSource(bytesRef); client().search(searchRequest).get(); fail("expected exception"); } catch (Exception ex) { @@ -191,7 +191,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest { } String query = "{ \"template\" : { \"query\": {\"match_all\": {}}, \"size\" : \"{{my_size}}\" }, \"params\" : { \"my_size\": 1 } }"; BytesReference bytesRef = new BytesArray(query); - searchRequest.templateSource(bytesRef, false); + searchRequest.templateSource(bytesRef); SearchResponse searchResponse = client().search(searchRequest).get(); assertThat(searchResponse.getHits().hits().length, equalTo(1)); diff --git a/src/test/java/org/elasticsearch/rest/RestRequestTests.java b/src/test/java/org/elasticsearch/rest/RestRequestTests.java index f4fc4f6cf28..1565455b604 100644 --- a/src/test/java/org/elasticsearch/rest/RestRequestTests.java +++ b/src/test/java/org/elasticsearch/rest/RestRequestTests.java @@ -71,11 +71,6 @@ public class RestRequestTests extends ElasticsearchTestCase { return false; } - @Override - public boolean contentUnsafe() { - return false; - } - @Override public BytesReference content() { return null; diff --git a/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java b/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java index 4277593e22e..bf76e8c3b5a 100644 --- a/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java +++ b/src/test/java/org/elasticsearch/search/geo/GeoFilterTests.java @@ -411,7 +411,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest { .string(); client().admin().indices().prepareCreate("countries").addMapping("country", mapping).execute().actionGet(); - BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, false, null, null).execute().actionGet(); + BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, null).execute().actionGet(); for (BulkItemResponse item : bulk.getItems()) { assertFalse("unable to index data", item.isFailed()); diff --git a/src/test/java/org/elasticsearch/test/rest/FakeRestRequest.java b/src/test/java/org/elasticsearch/test/rest/FakeRestRequest.java index 5f209734945..a24869b40bd 100644 --- a/src/test/java/org/elasticsearch/test/rest/FakeRestRequest.java +++ b/src/test/java/org/elasticsearch/test/rest/FakeRestRequest.java @@ -63,11 +63,6 @@ public class FakeRestRequest extends RestRequest { return false; } - @Override - public boolean contentUnsafe() { - return false; - } - @Override public BytesReference content() { return null;