diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index 64a3cb29a54..86ec8544994 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -676,7 +676,6 @@
-
@@ -1009,7 +1008,6 @@
-
diff --git a/buildSrc/version.properties b/buildSrc/version.properties
index 9fb8d89e824..357e5379e19 100644
--- a/buildSrc/version.properties
+++ b/buildSrc/version.properties
@@ -4,7 +4,8 @@ lucene = 6.1.0
# optional dependencies
spatial4j = 0.6
jts = 1.13
-jackson = 2.7.1
+jackson = 2.8.1
+snakeyaml = 1.15
log4j = 1.2.17
slf4j = 1.6.2
jna = 4.2.2
diff --git a/client/sniffer/licenses/jackson-core-2.7.1.jar.sha1 b/client/sniffer/licenses/jackson-core-2.7.1.jar.sha1
deleted file mode 100644
index 73831ed2d51..00000000000
--- a/client/sniffer/licenses/jackson-core-2.7.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-4127b62db028f981e81caa248953c0899d720f98
\ No newline at end of file
diff --git a/client/sniffer/licenses/jackson-core-2.8.1.jar.sha1 b/client/sniffer/licenses/jackson-core-2.8.1.jar.sha1
new file mode 100644
index 00000000000..b92131d6fab
--- /dev/null
+++ b/client/sniffer/licenses/jackson-core-2.8.1.jar.sha1
@@ -0,0 +1 @@
+fd13b1c033741d48291315c6370f7d475a42dccf
\ No newline at end of file
diff --git a/core/build.gradle b/core/build.gradle
index 2cf20b1c774..0e87c21757b 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -69,6 +69,7 @@ dependencies {
compile 'org.joda:joda-convert:1.2'
// json and yaml
+ compile "org.yaml:snakeyaml:${versions.snakeyaml}"
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java b/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java
index a7c541b84fc..dd95e0d1df5 100644
--- a/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java
+++ b/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.core.JsonStreamContext;
import com.fasterxml.jackson.core.base.GeneratorBase;
import com.fasterxml.jackson.core.filter.FilteringGeneratorDelegate;
import com.fasterxml.jackson.core.io.SerializedString;
+import com.fasterxml.jackson.core.json.JsonWriteContext;
import com.fasterxml.jackson.core.util.DefaultIndenter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import org.elasticsearch.common.bytes.BytesReference;
@@ -271,7 +272,9 @@ public class JsonXContentGenerator implements XContentGenerator {
public void writeEndRaw() {
assert base != null : "JsonGenerator should be of instance GeneratorBase but was: " + generator.getClass();
if (base != null) {
- base.getOutputContext().writeValue();
+ JsonStreamContext context = base.getOutputContext();
+ assert (context instanceof JsonWriteContext) : "Expected an instance of JsonWriteContext but was: " + context.getClass();
+ ((JsonWriteContext) context).writeValue();
}
}
diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java b/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java
index fbdf66e73ee..5728e6035e6 100644
--- a/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java
+++ b/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java
@@ -87,11 +87,6 @@ public class JsonXContentParser extends AbstractXContentParser {
@Override
public BytesRef utf8Bytes() throws IOException {
- // Tentative workaround for https://github.com/elastic/elasticsearch/issues/8629
- // TODO: Remove this when we upgrade jackson to 2.6.x.
- if (parser.getTextLength() == 0) {
- return new BytesRef();
- }
return new BytesRef(CharBuffer.wrap(parser.getTextCharacters(), parser.getTextOffset(), parser.getTextLength()));
}
diff --git a/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java b/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java
index 690f49171a6..2eab8674bdd 100644
--- a/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java
+++ b/core/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java
@@ -44,19 +44,33 @@ import static org.hamcrest.Matchers.nullValue;
public class MultiSearchRequestTests extends ESTestCase {
public void testSimpleAdd() throws Exception {
MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/simple-msearch1.json");
- assertThat(request.requests().size(), equalTo(8));
- assertThat(request.requests().get(0).indices()[0], equalTo("test"));
- assertThat(request.requests().get(0).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
- assertThat(request.requests().get(0).types().length, equalTo(0));
- assertThat(request.requests().get(1).indices()[0], equalTo("test"));
- assertThat(request.requests().get(1).indicesOptions(), equalTo(IndicesOptions.fromOptions(false, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
- assertThat(request.requests().get(1).types()[0], equalTo("type1"));
- assertThat(request.requests().get(2).indices()[0], equalTo("test"));
- assertThat(request.requests().get(2).indicesOptions(), equalTo(IndicesOptions.fromOptions(false, true, true, false, IndicesOptions.strictExpandOpenAndForbidClosed())));
- assertThat(request.requests().get(3).indices()[0], equalTo("test"));
- assertThat(request.requests().get(3).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
- assertThat(request.requests().get(4).indices()[0], equalTo("test"));
- assertThat(request.requests().get(4).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, false, false, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
+ assertThat(request.requests().size(),
+ equalTo(8));
+ assertThat(request.requests().get(0).indices()[0],
+ equalTo("test"));
+ assertThat(request.requests().get(0).indicesOptions(),
+ equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
+ assertThat(request.requests().get(0).types().length,
+ equalTo(0));
+ assertThat(request.requests().get(1).indices()[0],
+ equalTo("test"));
+ assertThat(request.requests().get(1).indicesOptions(),
+ equalTo(IndicesOptions.fromOptions(false, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
+ assertThat(request.requests().get(1).types()[0],
+ equalTo("type1"));
+ assertThat(request.requests().get(2).indices()[0],
+ equalTo("test"));
+ assertThat(request.requests().get(2).indicesOptions(),
+ equalTo(IndicesOptions.fromOptions(false, true, true, false, IndicesOptions.strictExpandOpenAndForbidClosed())));
+ assertThat(request.requests().get(3).indices()[0],
+ equalTo("test"));
+ assertThat(request.requests().get(3).indicesOptions(),
+ equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
+ assertThat(request.requests().get(4).indices()[0],
+ equalTo("test"));
+ assertThat(request.requests().get(4).indicesOptions(),
+ equalTo(IndicesOptions.fromOptions(true, false, false, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
+
assertThat(request.requests().get(5).indices(), is(Strings.EMPTY_ARRAY));
assertThat(request.requests().get(5).types().length, equalTo(0));
assertThat(request.requests().get(6).indices(), is(Strings.EMPTY_ARRAY));
@@ -119,10 +133,27 @@ public class MultiSearchRequestTests extends ESTestCase {
}
public void testResponseErrorToXContent() throws IOException {
- MultiSearchResponse response = new MultiSearchResponse(new MultiSearchResponse.Item[]{new MultiSearchResponse.Item(null, new IllegalStateException("foobar")), new MultiSearchResponse.Item(null, new IllegalStateException("baaaaaazzzz"))});
+ MultiSearchResponse response = new MultiSearchResponse(
+ new MultiSearchResponse.Item[]{
+ new MultiSearchResponse.Item(null, new IllegalStateException("foobar")),
+ new MultiSearchResponse.Item(null, new IllegalStateException("baaaaaazzzz"))
+ });
+
XContentBuilder builder = XContentFactory.jsonBuilder();
+ builder.startObject();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
- assertEquals("\"responses\"[{\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"}],\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"},\"status\":500},{\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"}],\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"},\"status\":500}]",
+ builder.endObject();
+
+ assertEquals("{\"responses\":["
+ + "{"
+ + "\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"}],"
+ + "\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"},\"status\":500"
+ + "},"
+ + "{"
+ + "\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"}],"
+ + "\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"},\"status\":500"
+ + "}"
+ + "]}",
builder.string());
}
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
index fe69fc1f05d..d0e095e8c65 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java
@@ -356,6 +356,7 @@ public class XContentBuilderTests extends ESTestCase {
public void testWriteFieldMapWithNullKeys() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
try {
+ builder.startObject();
builder.field("map", Collections.singletonMap(null, "test"));
fail("write map should have failed");
} catch(IllegalArgumentException e) {
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java
index 002d06b7d60..0fd3b9aa359 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java
@@ -319,9 +319,12 @@ public class TextFieldMapperTests extends ESSingleNodeTestCase {
.endObject()
.endObject().endObject().endObject().string();
mapper = parser.parse("type", new CompressedXContent(mapping));
- XContentBuilder builder = XContentFactory.jsonBuilder();
+ XContentBuilder builder = XContentFactory.jsonBuilder();
+ builder.startObject();
mapper.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap("include_defaults", "true")));
+ builder.endObject();
+
String mappingString = builder.string();
assertTrue(mappingString.contains("analyzer"));
assertTrue(mappingString.contains("search_analyzer"));
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
index 416774b1be4..f6dc921687d 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java
@@ -337,9 +337,12 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
.endObject()
.endObject().endObject().endObject().string();
mapper = parser.parse("type", new CompressedXContent(mapping));
- XContentBuilder builder = XContentFactory.jsonBuilder();
+ XContentBuilder builder = XContentFactory.jsonBuilder();
+ builder.startObject();
mapper.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap("include_defaults", "true")));
+ builder.endObject();
+
String mappingString = builder.string();
assertTrue(mappingString.contains("analyzer"));
assertTrue(mappingString.contains("search_analyzer"));
diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
index c9b3daa806a..12ac2910a4b 100644
--- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
+++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
@@ -42,6 +42,9 @@ import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
+import org.elasticsearch.common.xcontent.ToXContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.translog.Translog.Location;
@@ -351,10 +354,14 @@ public class TranslogTests extends ESTestCase {
assertEquals(6, copy.estimatedNumberOfOperations());
assertEquals(431, copy.getTranslogSizeInBytes());
- assertEquals("\"translog\"{\n" +
- " \"operations\" : 6,\n" +
- " \"size_in_bytes\" : 431\n" +
- "}", copy.toString().trim());
+
+ try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
+ builder.startObject();
+ copy.toXContent(builder, ToXContent.EMPTY_PARAMS);
+ builder.endObject();
+
+ assertEquals("{\"translog\":{\"operations\":6,\"size_in_bytes\":431}}", builder.string());
+ }
try {
new TranslogStats(1, -1);
diff --git a/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java b/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java
index 090517adfcd..7cd4e355218 100644
--- a/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java
+++ b/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java
@@ -109,9 +109,14 @@ public class NodeInfoStreamingTests extends ESTestCase {
private void compareJsonOutput(ToXContent param1, ToXContent param2) throws IOException {
ToXContent.Params params = ToXContent.EMPTY_PARAMS;
XContentBuilder param1Builder = jsonBuilder();
- XContentBuilder param2Builder = jsonBuilder();
+ param1Builder.startObject();
param1.toXContent(param1Builder, params);
+ param1Builder.endObject();
+
+ XContentBuilder param2Builder = jsonBuilder();
+ param2Builder.startObject();
param2.toXContent(param2Builder, params);
+ param2Builder.endObject();
assertThat(param1Builder.string(), equalTo(param2Builder.string()));
}
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java
index 1027a1097a1..512d42d4e79 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java
@@ -35,6 +35,7 @@ import org.elasticsearch.script.NativeScriptFactory;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.aggregations.Aggregation;
+import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
import org.elasticsearch.search.aggregations.bucket.script.NativeSignificanceScoreScriptNoParams;
import org.elasticsearch.search.aggregations.bucket.script.NativeSignificanceScoreScriptWithParams;
@@ -116,7 +117,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
.execute()
.actionGet();
assertSearchResponse(response);
- StringTerms classes = (StringTerms) response.getAggregations().get("class");
+ StringTerms classes = response.getAggregations().get("class");
assertThat(classes.getBuckets().size(), equalTo(2));
for (Terms.Bucket classBucket : classes.getBuckets()) {
Map aggs = classBucket.getAggregations().asMap();
@@ -246,7 +247,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
}
public void testXContentResponse() throws Exception {
- String type = false || randomBoolean() ? "text" : "long";
+ String type = randomBoolean() ? "text" : "long";
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
@@ -254,7 +255,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
.execute()
.actionGet();
assertSearchResponse(response);
- StringTerms classes = (StringTerms) response.getAggregations().get("class");
+ StringTerms classes = response.getAggregations().get("class");
assertThat(classes.getBuckets().size(), equalTo(2));
for (Terms.Bucket classBucket : classes.getBuckets()) {
Map aggs = classBucket.getAggregations().asMap();
@@ -267,13 +268,39 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
}
XContentBuilder responseBuilder = XContentFactory.jsonBuilder();
+ responseBuilder.startObject();
classes.toXContent(responseBuilder, null);
- String result = null;
- if (type.equals("long")) {
- result = "\"class\"{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,\"buckets\":[{\"key\":\"0\",\"doc_count\":4,\"sig_terms\":{\"doc_count\":4,\"buckets\":[{\"key\":0,\"doc_count\":4,\"score\":0.39999999999999997,\"bg_count\":5}]}},{\"key\":\"1\",\"doc_count\":3,\"sig_terms\":{\"doc_count\":3,\"buckets\":[{\"key\":1,\"doc_count\":3,\"score\":0.75,\"bg_count\":4}]}}]}";
- } else {
- result = "\"class\"{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,\"buckets\":[{\"key\":\"0\",\"doc_count\":4,\"sig_terms\":{\"doc_count\":4,\"buckets\":[{\"key\":\"0\",\"doc_count\":4,\"score\":0.39999999999999997,\"bg_count\":5}]}},{\"key\":\"1\",\"doc_count\":3,\"sig_terms\":{\"doc_count\":3,\"buckets\":[{\"key\":\"1\",\"doc_count\":3,\"score\":0.75,\"bg_count\":4}]}}]}";
- }
+ responseBuilder.endObject();
+
+ String result = "{\"class\":{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,"
+ + "\"buckets\":["
+ + "{"
+ + "\"key\":\"0\","
+ + "\"doc_count\":4,"
+ + "\"sig_terms\":{"
+ + "\"doc_count\":4,"
+ + "\"buckets\":["
+ + "{"
+ + "\"key\":" + (type.equals("long") ? "0," : "\"0\",")
+ + "\"doc_count\":4,"
+ + "\"score\":0.39999999999999997,"
+ + "\"bg_count\":5"
+ + "}"
+ + "]"
+ + "}"
+ + "},"
+ + "{"
+ + "\"key\":\"1\","
+ + "\"doc_count\":3,"
+ + "\"sig_terms\":{"
+ + "\"doc_count\":3,"
+ + "\"buckets\":["
+ + "{"
+ + "\"key\":" + (type.equals("long") ? "1," : "\"1\",")
+ + "\"doc_count\":3,"
+ + "\"score\":0.75,"
+ + "\"bg_count\":4"
+ + "}]}}]}}";
assertThat(responseBuilder.string(), equalTo(result));
}
@@ -309,7 +336,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
}
indexRandom(true, false, indexRequestBuilderList);
- SearchResponse response1 = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
+ client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
.addAggregation(
terms("class")
.field(CLASS_FIELD)
@@ -334,7 +361,8 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
// 1. terms agg on class and significant terms
// 2. filter buckets and set the background to the other class and set is_background false
// both should yield exact same result
- public void testBackgroundVsSeparateSet(SignificanceHeuristic significanceHeuristicExpectingSuperset, SignificanceHeuristic significanceHeuristicExpectingSeparateSets) throws Exception {
+ public void testBackgroundVsSeparateSet(SignificanceHeuristic significanceHeuristicExpectingSuperset,
+ SignificanceHeuristic significanceHeuristicExpectingSeparateSets) throws Exception {
SearchResponse response1 = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
.addAggregation(terms("class")
@@ -364,18 +392,25 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
.execute()
.actionGet();
- SignificantTerms sigTerms0 = ((SignificantTerms) (((StringTerms) response1.getAggregations().get("class")).getBucketByKey("0").getAggregations().asMap().get("sig_terms")));
+ StringTerms classes = response1.getAggregations().get("class");
+
+ SignificantTerms sigTerms0 = ((SignificantTerms) (classes.getBucketByKey("0").getAggregations().asMap().get("sig_terms")));
assertThat(sigTerms0.getBuckets().size(), equalTo(2));
double score00Background = sigTerms0.getBucketByKey("0").getSignificanceScore();
double score01Background = sigTerms0.getBucketByKey("1").getSignificanceScore();
- SignificantTerms sigTerms1 = ((SignificantTerms) (((StringTerms) response1.getAggregations().get("class")).getBucketByKey("1").getAggregations().asMap().get("sig_terms")));
+ SignificantTerms sigTerms1 = ((SignificantTerms) (classes.getBucketByKey("1").getAggregations().asMap().get("sig_terms")));
double score10Background = sigTerms1.getBucketByKey("0").getSignificanceScore();
double score11Background = sigTerms1.getBucketByKey("1").getSignificanceScore();
- double score00SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("0")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("0").getSignificanceScore();
- double score01SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("0")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("1").getSignificanceScore();
- double score10SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("1")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("0").getSignificanceScore();
- double score11SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("1")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("1").getSignificanceScore();
+ Aggregations aggs = response2.getAggregations();
+
+ sigTerms0 = (SignificantTerms) ((InternalFilter) aggs.get("0")).getAggregations().getAsMap().get("sig_terms");
+ double score00SeparateSets = sigTerms0.getBucketByKey("0").getSignificanceScore();
+ double score01SeparateSets = sigTerms0.getBucketByKey("1").getSignificanceScore();
+
+ sigTerms1 = (SignificantTerms) ((InternalFilter) aggs.get("1")).getAggregations().getAsMap().get("sig_terms");
+ double score10SeparateSets = sigTerms1.getBucketByKey("0").getSignificanceScore();
+ double score11SeparateSets = sigTerms1.getBucketByKey("1").getSignificanceScore();
assertThat(score00Background, equalTo(score00SeparateSets));
assertThat(score01Background, equalTo(score01SeparateSets));
@@ -401,11 +436,15 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
.execute()
.actionGet();
assertSearchResponse(response);
- StringTerms classes = (StringTerms) response.getAggregations().get("class");
+ StringTerms classes = response.getAggregations().get("class");
assertThat(classes.getBuckets().size(), equalTo(2));
Iterator classBuckets = classes.getBuckets().iterator();
- Collection classA = ((SignificantTerms) classBuckets.next().getAggregations().get("mySignificantTerms")).getBuckets();
- Iterator classBBucketIterator = ((SignificantTerms) classBuckets.next().getAggregations().get("mySignificantTerms")).getBuckets().iterator();
+
+ Aggregations aggregations = classBuckets.next().getAggregations();
+ SignificantTerms sigTerms = aggregations.get("mySignificantTerms");
+
+ Collection classA = sigTerms.getBuckets();
+ Iterator classBBucketIterator = sigTerms.getBuckets().iterator();
assertThat(classA.size(), greaterThan(0));
for (SignificantTerms.Bucket classABucket : classA) {
SignificantTerms.Bucket classBBucket = classBBucketIterator.next();
@@ -462,8 +501,10 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
.actionGet();
assertSearchResponse(response);
for (Terms.Bucket classBucket : ((Terms) response.getAggregations().get("class")).getBuckets()) {
- for (SignificantTerms.Bucket bucket : ((SignificantTerms) classBucket.getAggregations().get("mySignificantTerms")).getBuckets()) {
- assertThat(bucket.getSignificanceScore(), is((double) bucket.getSubsetDf() + bucket.getSubsetSize() + bucket.getSupersetDf() + bucket.getSupersetSize()));
+ SignificantTerms sigTerms = classBucket.getAggregations().get("mySignificantTerms");
+ for (SignificantTerms.Bucket bucket : sigTerms.getBuckets()) {
+ assertThat(bucket.getSignificanceScore(),
+ is((double) bucket.getSubsetDf() + bucket.getSubsetSize() + bucket.getSupersetDf() + bucket.getSupersetSize()));
}
}
}
@@ -478,9 +519,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
} else {
script = new Script("native_significance_score_script_no_params", ScriptType.INLINE, "native", null);
}
- ScriptHeuristic scriptHeuristic = new ScriptHeuristic(script);
-
- return scriptHeuristic;
+ return new ScriptHeuristic(script);
}
private void indexRandomFrequencies01(String type) throws ExecutionException, InterruptedException {
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBoundsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBoundsTests.java
index 0950501b8ba..6b7e51cc90f 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBoundsTests.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBoundsTests.java
@@ -34,6 +34,7 @@ import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.ESTestCase;
+import org.elasticsearch.threadpool.ThreadPoolStats;
import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
@@ -41,6 +42,7 @@ import java.io.IOException;
import static java.lang.Math.max;
import static java.lang.Math.min;
+import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -149,9 +151,21 @@ public class ExtendedBoundsTests extends ESTestCase {
ExtendedBounds orig = randomExtendedBounds();
try (XContentBuilder out = JsonXContent.contentBuilder()) {
+ out.startObject();
orig.toXContent(out, ToXContent.EMPTY_PARAMS);
+ out.endObject();
+
try (XContentParser in = JsonXContent.jsonXContent.createParser(out.bytes())) {
- in.nextToken();
+ XContentParser.Token token = in.currentToken();
+ assertNull(token);
+
+ token = in.nextToken();
+ assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
+
+ token = in.nextToken();
+ assertThat(token, equalTo(XContentParser.Token.FIELD_NAME));
+ assertThat(in.currentName(), equalTo(ExtendedBounds.EXTENDED_BOUNDS_FIELD.getPreferredName()));
+
ExtendedBounds read = ExtendedBounds.PARSER.apply(in, () -> ParseFieldMatcher.STRICT);
assertEquals(orig, read);
} catch (Exception e) {
diff --git a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java
index fc0a8abac27..a7312f59406 100644
--- a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java
+++ b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolStatsTests.java
@@ -71,9 +71,11 @@ public class ThreadPoolStatsTests extends ESTestCase {
stats.add(new ThreadPoolStats.Stats(ThreadPool.Names.FORCE_MERGE, -1, 0, 0, 0, 0, 0L));
stats.add(new ThreadPoolStats.Stats(ThreadPool.Names.SAME, -1, 0, 0, 0, 0, 0L));
-
+ ThreadPoolStats threadPoolStats = new ThreadPoolStats(stats);
try (XContentBuilder builder = new XContentBuilder(XContentType.JSON.xContent(), os)) {
- new ThreadPoolStats(stats).toXContent(builder, ToXContent.EMPTY_PARAMS);
+ builder.startObject();
+ threadPoolStats.toXContent(builder, ToXContent.EMPTY_PARAMS);
+ builder.endObject();
}
try (XContentParser parser = XContentType.JSON.xContent().createParser(os.bytes())) {
@@ -81,7 +83,11 @@ public class ThreadPoolStatsTests extends ESTestCase {
assertNull(token);
token = parser.nextToken();
- assertThat(token, equalTo(XContentParser.Token.VALUE_STRING));
+ assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
+
+ token = parser.nextToken();
+ assertThat(token, equalTo(XContentParser.Token.FIELD_NAME));
+ assertThat(parser.currentName(), equalTo(ThreadPoolStats.Fields.THREAD_POOL));
token = parser.nextToken();
assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
diff --git a/distribution/licenses/jackson-core-2.7.1.jar.sha1 b/distribution/licenses/jackson-core-2.7.1.jar.sha1
deleted file mode 100644
index 73831ed2d51..00000000000
--- a/distribution/licenses/jackson-core-2.7.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-4127b62db028f981e81caa248953c0899d720f98
\ No newline at end of file
diff --git a/distribution/licenses/jackson-core-2.8.1.jar.sha1 b/distribution/licenses/jackson-core-2.8.1.jar.sha1
new file mode 100644
index 00000000000..b92131d6fab
--- /dev/null
+++ b/distribution/licenses/jackson-core-2.8.1.jar.sha1
@@ -0,0 +1 @@
+fd13b1c033741d48291315c6370f7d475a42dccf
\ No newline at end of file
diff --git a/distribution/licenses/jackson-dataformat-cbor-2.7.1.jar.sha1 b/distribution/licenses/jackson-dataformat-cbor-2.7.1.jar.sha1
deleted file mode 100644
index 19bb5e64610..00000000000
--- a/distribution/licenses/jackson-dataformat-cbor-2.7.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-4282418817ad2be26ce18739461499eae679390f
\ No newline at end of file
diff --git a/distribution/licenses/jackson-dataformat-cbor-2.8.1.jar.sha1 b/distribution/licenses/jackson-dataformat-cbor-2.8.1.jar.sha1
new file mode 100644
index 00000000000..7f1609bfd85
--- /dev/null
+++ b/distribution/licenses/jackson-dataformat-cbor-2.8.1.jar.sha1
@@ -0,0 +1 @@
+3a6fb7e75c9972559a78cf5cfc5a48a41a13ea40
\ No newline at end of file
diff --git a/distribution/licenses/jackson-dataformat-smile-2.7.1.jar.sha1 b/distribution/licenses/jackson-dataformat-smile-2.7.1.jar.sha1
deleted file mode 100644
index 45c78df1ba3..00000000000
--- a/distribution/licenses/jackson-dataformat-smile-2.7.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-9ccde45d574388371d2c4032d4b853e2d596777e
\ No newline at end of file
diff --git a/distribution/licenses/jackson-dataformat-smile-2.8.1.jar.sha1 b/distribution/licenses/jackson-dataformat-smile-2.8.1.jar.sha1
new file mode 100644
index 00000000000..114d656a388
--- /dev/null
+++ b/distribution/licenses/jackson-dataformat-smile-2.8.1.jar.sha1
@@ -0,0 +1 @@
+005b73867bc12224946fc67fc8d49d9f5e698d7f
\ No newline at end of file
diff --git a/distribution/licenses/jackson-dataformat-yaml-2.7.1.jar.sha1 b/distribution/licenses/jackson-dataformat-yaml-2.7.1.jar.sha1
deleted file mode 100644
index 01b442577b1..00000000000
--- a/distribution/licenses/jackson-dataformat-yaml-2.7.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-6c5235a523b7d720b2b0e1b850ea14083e342b07
\ No newline at end of file
diff --git a/distribution/licenses/jackson-dataformat-yaml-2.8.1.jar.sha1 b/distribution/licenses/jackson-dataformat-yaml-2.8.1.jar.sha1
new file mode 100644
index 00000000000..32ce0f74344
--- /dev/null
+++ b/distribution/licenses/jackson-dataformat-yaml-2.8.1.jar.sha1
@@ -0,0 +1 @@
+eb63166c723b0b4b9fb5298fca232a2f6612ec34
\ No newline at end of file
diff --git a/distribution/licenses/snakeyaml-1.15.jar.sha1 b/distribution/licenses/snakeyaml-1.15.jar.sha1
new file mode 100644
index 00000000000..48391d6d9e1
--- /dev/null
+++ b/distribution/licenses/snakeyaml-1.15.jar.sha1
@@ -0,0 +1 @@
+3b132bea69e8ee099f416044970997bde80f4ea6
\ No newline at end of file
diff --git a/distribution/licenses/snakeyaml-LICENSE.txt b/distribution/licenses/snakeyaml-LICENSE.txt
new file mode 100644
index 00000000000..d9a10c0d8e8
--- /dev/null
+++ b/distribution/licenses/snakeyaml-LICENSE.txt
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/distribution/licenses/snakeyaml-NOTICE.txt b/distribution/licenses/snakeyaml-NOTICE.txt
new file mode 100644
index 00000000000..b51464eee1f
--- /dev/null
+++ b/distribution/licenses/snakeyaml-NOTICE.txt
@@ -0,0 +1,24 @@
+***The art of simplicity is a puzzle of complexity.***
+
+## Overview ##
+[YAML](http://yaml.org) is a data serialization format designed for human readability and interaction with scripting languages.
+
+SnakeYAML is a YAML processor for the Java Virtual Machine.
+
+## SnakeYAML features ##
+
+* a **complete** [YAML 1.1 processor](http://yaml.org/spec/1.1/current.html). In particular, SnakeYAML can parse all examples from the specification.
+* Unicode support including UTF-8/UTF-16 input/output.
+* high-level API for serializing and deserializing native Java objects.
+* support for all types from the [YAML types repository](http://yaml.org/type/index.html).
+* relatively sensible error messages.
+
+## Info ##
+ * [Changes](https://bitbucket.org/asomov/snakeyaml/wiki/Changes)
+ * [Documentation](https://bitbucket.org/asomov/snakeyaml/wiki/Documentation)
+
+## Contribute ##
+* Mercurial DVCS is used to dance with the [source code](https://bitbucket.org/asomov/snakeyaml/src).
+* If you find a bug in SnakeYAML, please [file a bug report](https://bitbucket.org/asomov/snakeyaml/issues?status=new&status=open).
+* You may discuss SnakeYAML at
+[the mailing list](http://groups.google.com/group/snakeyaml-core).
\ No newline at end of file
diff --git a/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/50_multi_search_template.yaml b/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/50_multi_search_template.yaml
index a22b101bf67..8b8ffcf8ae9 100644
--- a/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/50_multi_search_template.yaml
+++ b/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/50_multi_search_template.yaml
@@ -98,7 +98,7 @@ setup:
query_type: "unknown"
- match: { responses.0.hits.total: 2 }
- - match: { responses.1.error.root_cause.0.type: json_parse_exception }
+ - match: { responses.1.error.root_cause.0.type: json_e_o_f_exception }
- match: { responses.1.error.root_cause.0.reason: "/Unexpected.end.of.input/" }
- match: { responses.2.hits.total: 1 }
- match: { responses.3.error.root_cause.0.type: parsing_exception }