From b81f5f61424631958328c1b3c991f4989e893907 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 10 Aug 2015 23:13:19 -0700 Subject: [PATCH] Revert "Merge pull request #11414 from rjernst/fix/2315" This reverts commit 937732b17d5f64d1f92957193dafc7a73bed7bc9, reversing changes made to 6fea6c542cca57710191ab23c76029e28e3f217b. --- .../elasticsearch/index/mapper/DocumentParser.java | 8 -------- .../mapper/source/DefaultSourceMappingTests.java | 14 -------------- 2 files changed, 22 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java index 9e60ef5caa8..6aa66f20d6f 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java @@ -25,7 +25,6 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexableField; import org.apache.lucene.util.CloseableThreadLocal; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.settings.Settings; @@ -128,13 +127,6 @@ class DocumentParser implements Closeable { parser.nextToken(); } - // try to parse the next token, this should be null if the object is ended properly - // but will throw a JSON exception if the extra tokens is not valid JSON (this will be handled by the catch) - if (Version.indexCreated(indexSettings).onOrAfter(Version.V_2_0_0_beta1)) { - token = parser.nextToken(); - assert token == null; // double check, in tests, that we didn't end parsing early - } - for (MetadataFieldMapper metadataMapper : mapping.metadataMappers) { metadataMapper.postParse(context); } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java index f6a4c30c863..6e055f7403d 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java @@ -309,18 +309,4 @@ public class DefaultSourceMappingTests extends ESSingleNodeTestCase { .endObject().endObject().string(); assertFalse(parser.parse(mapping).sourceMapper().isComplete()); } - - public void testSourceObjectContainsExtraTokens() throws Exception { - String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); - DocumentMapper documentMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping); - - try { - documentMapper.parse("test", "type", "1", new BytesArray("{}}")); // extra end object (invalid JSON) - fail("Expected parse exception"); - } catch (MapperParsingException e) { - assertNotNull(e.getRootCause()); - String message = e.getRootCause().getMessage(); - assertTrue(message, message.contains("Unexpected close marker '}'")); - } - } }