Standardize JSON serialization of V3 API model instant fields #1148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fractionionalnumber 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 shouldensure backwards compatibility as we run the server on Java 11 JDKs.