Materialize model during JSON deserialization #255
Merged
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, deserializing JSON to a courier model resulted in a model that would have lazily initialized fields. This means that if one of the fields was a custom Scala class with custom validation logic in the constructor or coercer, that validation logic would be ignored during deserialization time. Instead, it would run the first time the field was accessed, leading to exceptions thrown at unexpected places. This change forces materialization of the entire model during JSON deserialization time, and causes JSON deserialization to fail if an exception is thrown by the Scala constructor or coercer.