Repository navigation
Fail on custom scalars without visible properties written with a type or object id - #934
Merged
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
Fixes #932
Follow-up to #931. A custom scalar class without visible properties still lost its value when Jackson wrote a type id or an object id for it:
These are written as
{"@class": "..."}and{"@id": 1}, so the empty bean check from #931 didn't fire (it only looked at{}), and anOptionalparameter or an input object field silently gotTypedToken("default")orIdToken("default").Now the check fires for any bean serializer without properties, whatever ids it wrote. So these scalars go down the embedded value path like the ones in #931. In an
ObjectNodeargument that gives aPOJONodewith the value. Everywhere else it fails, since Jackson's polymorphic and object id deserializers can't read an embedded value (missing type id property '@class',Cannot deserialize value of type Integer). I think an error is better than a silent default here.I did have them working (native type ids on the embedded value, and binding the value to a generated object id), but it was a fair bit of Jackson plumbing with its own gaps, for scalars I don't think anyone has. So I dropped it. If someone runs into it, removing the annotation or adding a getter for the value works.
Release note: custom scalars without visible properties that Jackson writes with a type id (
@JsonTypeInfo) or an object id (@JsonIdentityInfo) now fail with an error instead of reaching the resolver as a default instance. InObjectNodearguments they're passed with their value.Checklist
Both new cases in
CustomScalarInputTestfail on master: theOptional, input object and list cases with@JsonTypeInfo/@JsonIdentityInforeturndefaultor error inconsistently, and theObjectNodecase gets{"@id":1}or errors.mvn clean verifypasses (432 tests). Also checked through the installed jar in a separate consumer project: on master theOptionalparameters returntyped defaultandid default, with this change they fail with the errors above.