Test n_string_iso_latin_1.json on Java Jackson actually fails
WydD opened this issue · 4 comments
WydD commented
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
public static void main(String[] args) throws IOException {
new ObjectMapper().readTree("[\"é\"]".getBytes("ISO-8859-1"));
}
}
It is marked as "succeed but should fail" in the table but this throws the following exception:
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22
at [Source: [B@10b48321; line: 1, column: 5]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidOther(UTF8StreamJsonParser.java:3548)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidOther(UTF8StreamJsonParser.java:3555)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._decodeUtf8_3fast(UTF8StreamJsonParser.java:3361)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2517)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(UTF8StreamJsonParser.java:2465)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(UTF8StreamJsonParser.java:315)
at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeArray(JsonNodeDeserializer.java:283)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:71)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:15)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2404)
I didnt test other encoding failures but this seems wrong.
Thanks for this study!
nst commented
That's not what I get here:
/usr/bin/java -jar parsers/test_java_jackson_2_8_4/TestJSONParsing.jar test_parsing/n_string_iso_latin_1.json
valid
Could you please try the same command?
WydD commented
It returns the same thing. But your test class is wrong, it converts the bytes into a string here https://github.com/nst/JSONTestSuite/blob/master/parsers/test_java_jackson_2_8_4/TestJSONParsing.java#L36
By default it uses the default encoding of the system. Fortunately Jackson supports the byte array input, if you just use byte[] and transfer it into readTree you obtain this
com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22
at [Source: [B@1134affc; line: 1, column: 5]
invalid
nst commented