Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

builder based search source is safe now

  • Loading branch information...
commit b113eb18fe25c6b36595b8bbc84807b574c459fa 1 parent 184a384
@kimchy kimchy authored
View
2  modules/elasticsearch/src/main/java/org/elasticsearch/action/count/CountRequest.java
@@ -100,7 +100,7 @@ public String queryHint() {
return this;
}
- @Override protected void beforeLocalFork() {
+ @Override protected void beforeStart() {
if (querySourceUnsafe) {
querySource = Arrays.copyOfRange(querySource, querySourceOffset, querySourceOffset + querySourceLength);
querySourceOffset = 0;
View
2  modules/elasticsearch/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java
@@ -325,7 +325,7 @@ void beforeLocalFork() {
* more like this documents.
*/
public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) {
- BytesStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
+ BytesStream bos = sourceBuilder.buildAsBytesStream(Requests.CONTENT_TYPE);
this.searchSource = bos.underlyingBytes();
this.searchSourceOffset = 0;
this.searchSourceLength = bos.size();
View
8 modules/elasticsearch/src/main/java/org/elasticsearch/action/search/SearchRequest.java
@@ -261,11 +261,11 @@ public SearchRequest searchType(String searchType) throws ElasticSearchIllegalAr
* The source of the search request.
*/
public SearchRequest source(SearchSourceBuilder sourceBuilder) {
- BytesStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
+ BytesStream bos = sourceBuilder.buildAsBytesStream(Requests.CONTENT_TYPE);
this.source = bos.underlyingBytes();
this.sourceOffset = 0;
this.sourceLength = bos.size();
- this.sourceUnsafe = true;
+ this.sourceUnsafe = false;
return this;
}
@@ -356,11 +356,11 @@ public SearchRequest extraSource(SearchSourceBuilder sourceBuilder) {
extraSource = null;
return this;
}
- BytesStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
+ BytesStream bos = sourceBuilder.buildAsBytesStream(Requests.CONTENT_TYPE);
this.extraSource = bos.underlyingBytes();
this.extraSourceOffset = 0;
this.extraSourceLength = bos.size();
- this.extraSourceUnsafe = true;
+ this.extraSourceUnsafe = false;
return this;
}
View
4 ...es/elasticsearch/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java
@@ -96,6 +96,10 @@ public BroadcastOperationRequest operationThreading(String operationThreading) {
return operationThreading(BroadcastOperationThreading.fromString(operationThreading, this.operationThreading));
}
+ protected void beforeStart() {
+
+ }
+
protected void beforeLocalFork() {
}
View
1  ...icsearch/src/main/java/org/elasticsearch/action/support/broadcast/TransportBroadcastOperationAction.java
@@ -156,6 +156,7 @@ public void start() {
// no shards
listener.onResponse(newResponse(request, new AtomicReferenceArray(0), clusterState));
}
+ request.beforeStart();
// count the local operations, and perform the non local ones
int localOperations = 0;
for (final ShardIterator shardIt : shardsIts) {
View
2  modules/elasticsearch/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java
@@ -495,7 +495,7 @@ public SearchSourceBuilder stats(String... statsGroups) {
}
}
- public BytesStream buildAsUnsafeBytes(XContentType contentType) throws SearchSourceBuilderException {
+ public BytesStream buildAsBytesStream(XContentType contentType) throws SearchSourceBuilderException {
try {
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
toXContent(builder, ToXContent.EMPTY_PARAMS);
Please sign in to comment.
Something went wrong with that request. Please try again.