jackson-docs icon indicating copy to clipboard operation
jackson-docs copied to clipboard

Upgrade to 2.12.4, default deserialization to 1970-1-1 if the date is null

Open 360631935 opened this issue 2 years ago • 1 comments

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.

360631935 avatar Feb 08 '23 02:02 360631935

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.

cowtowncoder avatar Feb 13 '23 02:02 cowtowncoder

I found the solution 🥳

You must set the behaviour of coercionConfigFor:

XmlMapper mapper = new XmlMapper();
mapper.coercionConfigFor( LogicalType.DateTime ).setCoercion( CoercionInputShape.EmptyString, CoercionAction.AsNull );

danibs avatar Aug 05 '24 16:08 danibs

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

360631935 avatar Aug 07 '24 01:08 360631935