I’ve just come across what I believe is a weird behaviour in Jackson XML (de)serialization.
The character uFFFF
is accepted when serializing but leads to an error when deserialized.
XmlMapper xml = new XmlMapper();
String xmlString = xml.writeValueAsString("Some valid string but containing the uFFFF character");
System.out.println(xmlString);
// <String>Some valid string but containing the  character</String>
String deser = xml.readValue(xmlString, String.class);
System.out.println(deser);
// java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Illegal character entity: expansion character (code 0xffff
// at [row,col {unknown-source}]: [1,53]
// at [Source: (StringReader); line: 1, column: 54]
What is the proper way of handling this? How to tell Jackson to not write this character if it doesn’t support reading it back?
(Jackson version: 2.17.1)