1

We are facing some weird behavior with date serializations with Jackson. It is happening very rarely.

In one example, we send a POST request with a serialized date in format:

public static String createUTCdateString() {
    //Time in GMT
    SimpleDateFormat simpleDateFormatUTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    simpleDateFormatUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
    return simpleDateFormatUTC.format(new Date());
}

We made 2 posts with 2ms difference, in the logs I see the dates are serialized as :

"2019-02-25T08:02:47.950Z"
"2019-02-25T08:02:47.952Z"

on reception, the date is deserialized to DTO with the wrong date. 2nd event has a date 4701 instead of 2019.

date=Mon Feb 25 08:02:47 UTC 2019, 
date=Mon Feb 25 08:02:47 UTC 4701,

The field in the DTO is as follows:

@NotNull
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    private Date date;

Why would this happen?

Weirdly, I could not find anything related to this. Any help is appreciated.

EDIT:

The serializing component is of Vertx 3.5.1 using Jackson 2.9.3 apparently. https://github.com/vert-x3/wiki/wiki/3.5.1-Release-Notes

The deserializing component is of Spring Boot using Jackson 2.8.x enter image description here

Orkun
  • 6,998
  • 8
  • 56
  • 103
  • 1
    Could you please provide an insight in your dependency overview regarding the Jackson libs? I'm curious about potentially mismatching versions. – mle Mar 14 '19 at 15:10
  • good thinking! that maybe why. updated the question – Orkun Mar 14 '19 at 20:10
  • Hm, Jackson in 2.8.x seems that you are using Spring Boot 1.5.x, correct? Is an upgrade to Spring Boot 2 feasible for you to see if a potential bug is fixed in one of the managed dependencies? – mle Mar 14 '19 at 21:06
  • indeed we re on org.springframework.boot 1.5.9.RELEASE – Orkun Mar 15 '19 at 08:32
  • And could you give an update to Spring Boot 2 a try? All deserializing tests here on my side look fine with your setup. Is this always reproducible? May be you could dig further into this by writing a little deserializing unit test which executes with different delays or types of concurrency. I also found no corresponding Jackson issues. – mle Mar 15 '19 at 09:02
  • I will try to do that test. Thank you for your input! I donT know if a spring boot upgrade is an option though.. – Orkun Mar 15 '19 at 09:46
  • Ok, feel free to figure out the other options mentioned above and keep me updated on your progress. – mle Mar 15 '19 at 13:14

0 Answers0