better auto identification of xson content

This commit is contained in:
kimchy 2010-04-30 02:47:27 +03:00
parent 976749e0a1
commit 650eb19622
1 changed files with 1 additions and 2 deletions

View File

@ -23,7 +23,6 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.util.xcontent.builder.BinaryXContentBuilder; import org.elasticsearch.util.xcontent.builder.BinaryXContentBuilder;
import org.elasticsearch.util.xcontent.builder.TextXContentBuilder; import org.elasticsearch.util.xcontent.builder.TextXContentBuilder;
import org.elasticsearch.util.xcontent.json.JsonXContent; import org.elasticsearch.util.xcontent.json.JsonXContent;
import org.elasticsearch.util.xcontent.xson.XsonType;
import org.elasticsearch.util.xcontent.xson.XsonXContent; import org.elasticsearch.util.xcontent.xson.XsonXContent;
import java.io.IOException; import java.io.IOException;
@ -147,7 +146,7 @@ public class XContentFactory {
*/ */
public static XContentType xContentType(byte[] data, int offset, int length) { public static XContentType xContentType(byte[] data, int offset, int length) {
length = length < GUESS_HEADER_LENGTH ? length : GUESS_HEADER_LENGTH; length = length < GUESS_HEADER_LENGTH ? length : GUESS_HEADER_LENGTH;
if (length > 1 && data[0] == XsonType.HEADER) { if (length > 1 && data[0] == 0x00 && data[1] == 0x00) {
return XContentType.XSON; return XContentType.XSON;
} }
for (int i = offset; i < length; i++) { for (int i = offset; i < length; i++) {