-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
@JsonSerialize(contentAs=superType)
behavior disallowed in 2.7
#1178
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
Comments
Sounds like earlier versions did not verify that types are compatible. Assuming |
Our inheritance tree looks something like this:
I'm trying to limit what gets serialized here to only the properties defined in BaseAccessionIdentifier. Do I need to define a custom serializer in this case? |
@markwoon Hmmh. I can see that although such definition is not necessarily safe for all usage (since you could have alternative So perhaps this is a flaw after all. |
@cowtowncoder Does that mean that this is something that might change a future release? And what would you recommend in the mean time? |
@markwoon Right, I think I will try to fix this for 2.7.4. In the meantime... good question. I am not sure if there is an easier way than custom serializer. |
@JsonSerialize(contentAs=superType)
behavior disallowed in 2.7
I was able to fix this, will be included in 2.7.4. |
@cowtowncoder Confirming this works for collections, but not for single objects. This is failing:
Error message: com.fasterxml.jackson.databind.JsonMappingException: Failed to widen type [simple type, class org.pharmgkb.model.AccessionIdentifier] with annotation (value org.pharmgkb.model.BaseAccessionIdentifier), from 'getReference': Class org.pharmgkb.model.BaseAccessionIdentifier not a super-type of [simple type, class org.pharmgkb.model.AccessionIdentifier] |
@markwoon could you file a new issue with that? Along with either reproduction, or at least type definitions needed. Stack trace would be helpful as well. |
After updating to 2.7, I'm getting:
Failed to widen value type of [collection type; class java.util.SortedSet, contains [simple type, class org.pharmgkb.model.AccessionIdentifier]] with concrete-type annotation (value org.pharmgkb.model.BaseAccessionIdentifier), from 'getGenes': Class org.pharmgkb.model.BaseAccessionIdentifier not a super-type of [simple type, class org.pharmgkb.model.AccessionIdentifier]
The signature of the method in question is:
How am I suppose to annotate this to get it to work again?
The text was updated successfully, but these errors were encountered: