Netflix / genie

Distributed Big Data Orchestration Service
https://netflix.github.io/genie
Apache License 2.0
1.71k stars 367 forks source link

Standardize JSON serialization of V3 API model instant fields #1148

Closed tgianos closed 2 years ago

tgianos commented 2 years ago

Previously the JSON serialization relied on the default Jackson behavior which was to defer to toString() however that followed the ISO standard and would serialize to whatever fractionional number of digits were available. On Java 8 JDKs this was ok as it would always do milliseconds. On a Java 11 JDK it would expand to 6 digits of precision which still adhers to the spec. The problem was that within Netflix there is a widely used client with a long upgrade path that hardcoded some 3 digit precision expectation in its parsing rather than using a standard ISO8601 parsing library for the time strings returned by the API.

This change creates a custom serializer which truncates all available Instants to millisecond precition before preceeding with the standard serialization logic of calling toStriong(). This should ensure backwards compatibility as we run the server on Java 11 JDKs.

coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.01%) to 93.784% when pulling 3bc2205da1fc72e2effb271f54dc12d11e0b3b90 on tgianos:millisecondSerialization into 3f09f623ba69541ce1e06bb568647baff3d9e581 on Netflix:4.1.x.