-
Notifications
You must be signed in to change notification settings - Fork 96
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
Support retrieving lower bound from TypeVariable in Collection attribute #580
Conversation
@Verdent what do you think ? |
Hi @amoscatelli , Thank you for your contribution! |
@Verdent I closed the issue because I understood the issue is not about typevariable alone, but is about a combination of typevariable and something else. I need to research more, then I'll update the issue I opened before and if you want I'll repone the pull request. |
@Verdent hi again The issue is with TypeVariable (and NOT WildcardVariable) used to define a Collection of a wrapper generic class attribute. To get the TypeVariable (and not the WildcardVariable) I use reflection (see the getDeclaredField in the test). The same actually works if you use the generic to define a non collection attribute, in other words if you remove Collection from the attribute. The same works if you don't use a wrapper class too. In other words, these combinations work :
This combination doesn't work :
By patching Yasson internal TypeUtils I made this work, but I can't exclude there is something else wrong behind. Please let me know. |
This patch made my day (after loosing another one). I have a generic API where actual entries are not specified; public List<Resultset<T>> getResultSets() {
return result_sets;
} The server may put any jsonb annotated entries, but serialization on server side fails without the patch. D. P.S. I have attached the unit test for my case in a hope the patch is accepted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch definitely fixes the issue.
#579
The issue is related to TypeVariable having a GenericDeclaration different from the expected inherited one.
In the example described in the issue, the GenericDeclaration is FindRequestDTO, and that doesn't match with FindCriteriaDTO.
This is an issue for https://github.com/eclipse-ee4j/yasson/blob/master/src/main/java/org/eclipse/yasson/internal/VariableTypeInheritanceSearch.java#L98
Tell me if you need a more structured approach.
Thank you