From 86e17eae2ca524904ecb4ac0d078a11f987259ba Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 28 Sep 2010 00:01:35 +0200 Subject: [PATCH] fix auto conversion from source content type to rest content type --- .../rest/action/support/RestXContentBuilder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java index 0d4fb286f23..3b0c9c3f4db 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java @@ -69,8 +69,7 @@ public class RestXContentBuilder { if (contentType == builder.contentType()) { builder.rawField("_source", siLzf); } else { - // TODO, should we just return it as binary and not auto convert it? - XContentParser parser = XContentFactory.xContent(builder.contentType()).createParser(siLzf); + XContentParser parser = XContentFactory.xContent(contentType).createParser(siLzf); try { parser.nextToken(); builder.field("_source"); @@ -80,11 +79,11 @@ public class RestXContentBuilder { } } } else { - if (XContentFactory.xContentType(source) == builder.contentType()) { + XContentType contentType = XContentFactory.xContentType(source); + if (contentType == builder.contentType()) { builder.rawField("_source", source); } else { - // TODO, should we just return it as binary and not auto convert it? - XContentParser parser = XContentFactory.xContent(builder.contentType()).createParser(source); + XContentParser parser = XContentFactory.xContent(contentType).createParser(source); try { parser.nextToken(); builder.field("_source");