-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Yasson is unable to deserialize an Optional<String> in native #10873
Comments
/cc @aguibert |
@loicmathieu would registering String's constructors for reflection in Quarkus not be enough? |
@geoand no idea, I didn't have time yet to investiguate on this issue. But I'm very surprise String didn't works OOTB with GraalVM ... |
Well, I think it's more that the String is created with reflection that causes the problem. I am pretty sure that if we register it for reflection, we'll be fine. We probably need to introspect the return types of the codecs and make sure we register things for reflection (similar to what we do for JAX-RS for example). |
OK, I think I understand what you means now ;) |
@geoand adding the following
Here is my test entity:
And here is my test resource:
I would expect as the So, for me, it's a bug in the resteasy extension right ? |
Yeah, that sounds true |
We exclude most of the |
The I don't know if we can do something about it, and if it's an issue on GraalVM side or on our side. For the moment I found a workaround by registering String for reflection from my Pojo Class via |
As I said, it's us not registering the |
@gsmet didn't find this in the code of resteasy or on core deployement steps related to registering types for reflection ... Looking at the code inside |
@gsmet thanks, adding Should I provides a PR for this ? |
I don't know. I don't understand why Yasson would work with a plain String and bail out on String reflection for an |
If I understand correctly how Yasson handle Optional, it creates new serializer / deserializer for the Optional value type and uses these, so normaly it should use the String Serializer / Deserializer that is used by the String attribute (the other attribute of my Pojo class). So it should work. See https://github.com/eclipse-ee4j/yasson/blob/master/src/main/java/org/eclipse/yasson/internal/serializer/OptionalObjectDeserializer.java#L54 and https://github.com/eclipse-ee4j/yasson/blob/master/src/main/java/org/eclipse/yasson/internal/serializer/OptionalObjectSerializer.java#L87 Maybe @aguibert can help us on this ? |
I think Yasson should perhaps check the "optionalValueType" and if it finds it to be a primitive type (like Given that there already is a workaround (specifically adding the reflection configuration for Graal) to get past this, I think it's perhaps better to wait and hear if yasson is willing to do this change, before introducing any wider change in Quarkus itself. |
@jaikiran my understanding is that Yasson already do this, that's how I understand the code here https://github.com/eclipse-ee4j/yasson/blob/master/src/main/java/org/eclipse/yasson/internal/serializer/OptionalObjectDeserializer.java#L54 and here https://github.com/eclipse-ee4j/yasson/blob/master/src/main/java/org/eclipse/yasson/internal/serializer/OptionalObjectSerializer.java#L87 |
@aguibert did you have time to look at this one ? I propose to add |
@gsmet @geoand @aguibert I want to move on for this one as one of my PR to fix an issue is waiting on it. Is adding |
Yeah, I don't think we want to register String for reflection TBH... If it's absolutely necessary, then I assume we only want to register its constructors |
@geoand the issue is that in this case we don't know if it's needed or not to register it. A solution will be to register it in any cases as it is highly probable that it is already registered for reflection and the case of this issue is just an odd case ... |
So yeah, I would prefer if in the jsonb extension we just register String's constructor for reflection and nothing else. |
OK, I'll give it a try |
PR #12045 workaround the issue by registering the constructors of String inside the jsonb extension. @gsmet suggested on the following comment to open an issue on Yasson: https://github.com/quarkusio/quarkus/pull/12045/files/ec0c7aaa39d758c31db1ff2f756710f4f1e42f18#r487019525 I don't know if it's a good idea as it's an issue with the usage of Yasson inside Quarkus. And I don't how to describe such issue. Yasson would not work on native if Quarkus didn't register all discovered types for reflection so creating a reproducer out of Quarkus could be realy challenging. |
Let's close this as it's no longer an issue and open a new one if still necessary |
Describe the bug
Yasson is unable to deserialize a POJO with an
Optional<String>
attribute in native mode.There is no issue in JVM mode.
There is no stacktrace, only the following SEVER log:
Expected behavior
Deserializing an
Optional<String>
works in both native and JVM mode.To Reproduce
Running the mongodb-client integration test from the following branch: https://github.com/loicmathieu/quarkus/tree/mongodb/property-codec-provider/integration-tests/mongodb-client
Environment (please complete the following information):
uname -a
orver
: Linux 5.4.0-40-generic Arc - request context propagation #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64 x86_64 x86_64 GNU/Linuxjava -version
: openjdk version "11.0.7" 2020-04-14The text was updated successfully, but these errors were encountered: