Enable strict duplicate checks for JSON content
With this commit we enable the Jackson feature 'STRICT_DUPLICATE_DETECTION' by default. This ensures that JSON keys are always unique. While this has a performance impact, benchmarking has indicated that the typical drop in indexing throughput is around 1 - 2%. As a last resort, we allow users to still disable strict duplicate checks by setting `-Des.json.strict_duplicate_detection=false` which is intentionally undocumented. Relates elastic/elasticsearchelastic/elasticsearch#19614 Relates elastic/elasticsearchelastic/elasticsearch#22073 Original commit: elastic/x-pack-elasticsearch@47055336e3
This commit is contained in:
commit
911aec0502
|
@ -10,6 +10,7 @@ import org.elasticsearch.common.ParseField;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
|
@ -114,6 +115,8 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatTwoAttachmentsWithTheSameIdThrowError() throws Exception {
|
||||
assumeFalse("Test only makes sense if JSON parser doesn't have strict duplicate checks enabled",
|
||||
JsonXContent.isStrictDuplicateDetectionEnabled());
|
||||
Map<String, EmailAttachmentParser> parsers = new HashMap<>();
|
||||
parsers.put("test", new TestEmailAttachmentParser());
|
||||
EmailAttachmentsParser parser = new EmailAttachmentsParser(parsers);
|
||||
|
|
|
@ -264,9 +264,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
}
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (textBody != null || htmlBody != null) {
|
||||
} else if (textBody != null || htmlBody != null) {
|
||||
builder.startObject("body");
|
||||
if (textBody != null) {
|
||||
if (randomBoolean()) {
|
||||
|
|
|
@ -194,6 +194,8 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParseContainsDuplicateOperator() throws IOException {
|
||||
assumeFalse("Test only makes sense if JSON parser doesn't have strict duplicate checks enabled",
|
||||
JsonXContent.isStrictDuplicateDetectionEnabled());
|
||||
ArrayCompareCondition.Op op = randomFrom(ArrayCompareCondition.Op.values());
|
||||
ArrayCompareCondition.Quantifier quantifier = randomFrom(ArrayCompareCondition.Quantifier.values());
|
||||
Object value = randomFrom("value", 1, null);
|
||||
|
@ -245,6 +247,8 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParseContainsDuplicateValue() throws IOException {
|
||||
assumeFalse("Test only makes sense if JSON parser doesn't have strict duplicate checks enabled",
|
||||
JsonXContent.isStrictDuplicateDetectionEnabled());
|
||||
ArrayCompareCondition.Op op = randomFrom(ArrayCompareCondition.Op.values());
|
||||
ArrayCompareCondition.Quantifier quantifier = randomFrom(ArrayCompareCondition.Quantifier.values());
|
||||
Object value = randomFrom("value", 1, null);
|
||||
|
@ -270,6 +274,8 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParseContainsDuplicateQuantifier() throws IOException {
|
||||
assumeFalse("Test only makes sense if JSON parser doesn't have strict duplicate checks enabled",
|
||||
JsonXContent.isStrictDuplicateDetectionEnabled());
|
||||
ArrayCompareCondition.Op op = randomFrom(ArrayCompareCondition.Op.values());
|
||||
ArrayCompareCondition.Quantifier quantifier = randomFrom(ArrayCompareCondition.Quantifier.values());
|
||||
Object value = randomFrom("value", 1, null);
|
||||
|
|
Loading…
Reference in New Issue