jackson-docs
jackson-docs copied to clipboard
Upgrade to 2.12.4, default deserialization to 1970-1-1 if the date is null
Spring Boot was upgraded to 2.5.4, Jackson 2.12.4, and the default value of 1970-1-1 was deserialized when no value was passed in the date field in the XML message. I didn't find a way to configure the solution. I had to choose to downgrade the Jackson version and currently use 2.9.10 to fix the 1970 default date.
This is not the right place to report such issues; but if you can create a stand-alone unit test (no Spring Boot dependencies, need to isolate), it'd make sense to report at:
https://github.com/FasterXML/jackson-dataformat-xml/issues
but definitely need more detail on exactly what XML, target POJO, XmlMapper
configuration etc.
I found the solution 🥳
You must set the behaviour of coercionConfigFor
:
XmlMapper mapper = new XmlMapper();
mapper.coercionConfigFor( LogicalType.DateTime ).setCoercion( CoercionInputShape.EmptyString, CoercionAction.AsNull );
I found the solution 🥳
You must set the behaviour of
coercionConfigFor
:XmlMapper mapper = new XmlMapper(); mapper.coercionConfigFor( LogicalType.DateTime ).setCoercion( CoercionInputShape.EmptyString, CoercionAction.AsNull );
Thank you. My solution is the same as yours