|
18 | 18 | import org.elasticsearch.xcontent.XContent; |
19 | 19 | import org.elasticsearch.xcontent.XContentBuilder; |
20 | 20 | import org.elasticsearch.xcontent.XContentGenerator; |
| 21 | +import org.elasticsearch.xcontent.XContentParseException; |
21 | 22 | import org.elasticsearch.xcontent.XContentParser; |
22 | 23 | import org.elasticsearch.xcontent.XContentParserConfiguration; |
23 | 24 | import org.elasticsearch.xcontent.XContentType; |
24 | 25 | import org.elasticsearch.xcontent.provider.XContentImplUtils; |
25 | 26 |
|
| 27 | +import java.io.CharConversionException; |
26 | 28 | import java.io.IOException; |
27 | 29 | import java.io.InputStream; |
28 | 30 | import java.io.OutputStream; |
@@ -96,21 +98,37 @@ private XContentParser createParser(XContentParserConfiguration config, JsonPars |
96 | 98 |
|
97 | 99 | @Override |
98 | 100 | public XContentParser createParser(XContentParserConfiguration config, String content) throws IOException { |
99 | | - return createParser(config, jsonFactory.createParser(content)); |
| 101 | + try { |
| 102 | + return createParser(config, jsonFactory.createParser(content)); |
| 103 | + } catch (CharConversionException e) { |
| 104 | + throw new XContentParseException(null, e.getMessage(), e); |
| 105 | + } |
100 | 106 | } |
101 | 107 |
|
102 | 108 | @Override |
103 | 109 | public XContentParser createParser(XContentParserConfiguration config, InputStream is) throws IOException { |
104 | | - return createParser(config, jsonFactory.createParser(is)); |
| 110 | + try { |
| 111 | + return createParser(config, jsonFactory.createParser(is)); |
| 112 | + } catch (CharConversionException e) { |
| 113 | + throw new XContentParseException(null, e.getMessage(), e); |
| 114 | + } |
105 | 115 | } |
106 | 116 |
|
107 | 117 | @Override |
108 | 118 | public XContentParser createParser(XContentParserConfiguration config, byte[] data, int offset, int length) throws IOException { |
| 119 | + try { |
109 | 120 | return createParser(config, jsonFactory.createParser(data, offset, length)); |
| 121 | + } catch (CharConversionException e) { |
| 122 | + throw new XContentParseException(null, e.getMessage(), e); |
| 123 | + } |
110 | 124 | } |
111 | 125 |
|
112 | 126 | @Override |
113 | 127 | public XContentParser createParser(XContentParserConfiguration config, Reader reader) throws IOException { |
| 128 | + try { |
114 | 129 | return createParser(config, jsonFactory.createParser(reader)); |
| 130 | + } catch (CharConversionException e) { |
| 131 | + throw new XContentParseException(null, e.getMessage(), e); |
| 132 | + } |
115 | 133 | } |
116 | 134 | } |
0 commit comments