Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize JSON serialization of V3 API model instant fields #1148

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

tgianos
Copy link
Contributor

@tgianos tgianos commented Jan 27, 2022

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.

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.
@tgianos tgianos added this to the 4.1.2 milestone Jan 27, 2022
@tgianos tgianos requested a review from nvhoang January 27, 2022 18:39
@coveralls
Copy link

Coverage Status

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

@tgianos tgianos merged commit 12fa839 into Netflix:4.1.x Jan 27, 2022
@tgianos tgianos deleted the millisecondSerialization branch January 27, 2022 19:57
@tgianos tgianos changed the title Standardize JSON serialization of V3 API model insant fields Standardize JSON serialization of V3 API model instant fields Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants