Skip to content

Commit 71c6eed

Browse files
committed
Add custom UTF8Reader (repurposed form YAML/CSV, should probably consider adding in jackson-core for 3.0)
1 parent 87fd10f commit 71c6eed

File tree

2 files changed

+456
-2
lines changed

2 files changed

+456
-2
lines changed

toml/src/main/java/com/fasterxml/jackson/dataformat/toml/TomlFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ public int getFormatParserFeatures() {
214214
@Override
215215
public JsonParser _createParser(InputStream in, IOContext ctxt) throws IOException {
216216
// "A TOML file must be a valid UTF-8 encoded Unicode document."
217-
return _createParser(new InputStreamReader(in, StandardCharsets.UTF_8), ctxt);
217+
boolean autoClose = ctxt.isResourceManaged() || isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE);
218+
return _createParser(UTF8Reader.construct(ctxt, in, autoClose),
219+
ctxt);
218220
}
219221

220222
@Override
@@ -225,7 +227,7 @@ public JsonParser _createParser(Reader r, IOContext ctxt) throws IOException {
225227

226228
@Override
227229
public JsonParser _createParser(byte[] data, int offset, int len, IOContext ctxt) throws IOException {
228-
return _createParser(new ByteArrayInputStream(data, offset, len), ctxt);
230+
return _createParser(UTF8Reader.construct(data, offset, len), ctxt);
229231
}
230232

231233
@Override

0 commit comments

Comments
 (0)