-
Notifications
You must be signed in to change notification settings - Fork 81
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
JacksonJaxbJsonProvider should use the real "value.getClass()" to build the root type #87
Comments
I would just strongly recommend never returning instance of generic type, regardless of whether returning can be made to work. It's just a constant source of problems. I don't have current plans to work on trying to improve handling of JAX-RS endpoint. |
Ok and before you get serious time to work on the improvment, is there any chance we can get any modification such as following one :
would become
It will only affect cases where the generic entity raw type is different from the real entity type and only for user custom generic type. Cases where generic type represents a Collection or Map of any sort will not be affected.
Am I missing other potential impacts ? Do you think this is acceptable as a temporary solution ? |
@NicoNes I was about to say that this shouldn't do anything, before I noticed that it actually might, if Would it be possible to write a simple test case to show how change would solve a problem? I haven't used |
@NicoNes I think what I'd like to do is to just proceed with pushing 2.8.0 of providers, for now, and with suitable tests I am open to improving type resolution where it makes sense. One concern I do have about code suggested is just that it seems wrong for So that's a long way of saying that I don't know expected valid usage (perhaps supported by JAX-RS documentation), and with additional tests I could learn more. |
Hi @cowtowncoder, I just created the PR #89 and added two comments. The first one is about the fact that both jersey and resteasy can't coexist properly at runtime. The second is about a behavior I noticed but I don't understand. Maybe you can help me with it. |
Hmmh. Odd -- it does not make sense to me; raw type can not be Now, types certainly ought to be related (either same type-erased class, or one is sub-class of the other), but even there it is not clear if it should always be that one is subtype of the other. I'll have a look at PR so I hope it clarifies the issue. |
Yes my bad sorry. I switched To be clearer, if the server side returns:
then
In this case
Else If server side returns
then
In this case
Javadoc just mention that instance passed to GenericEntity constructor must be of type T so both of the previous cases are legal. |
Sure, I understand you're perspective 👍 |
Fixed via #89 |
Hi,
I saw your comment in the code (JacksonJaxbJsonProvider.writeTo() method) :
/* * This is still not exactly right; should root type be * further specialized with 'value.getClass()'? Let's see * how well this works before trying to come up with more * complete solution. */ rootType = writer.getTypeFactory().constructType(genericType);
so I suppose you already know the issue.I have two types :
and
My service returns
//Runtime time of page can be either PageImpl or any other sub type I can determine at compile time
The problem is that the all the annotations I put into PageImpl will not be taken into account for serialization.
Do you already have any fix or workaround ?
Thank you
The text was updated successfully, but these errors were encountered: