-
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
ObjectMapper of @CustomSerialization has no effect #34934
Labels
Comments
/cc @FroMage (resteasy-reactive), @Sgitario (resteasy-reactive), @stuartwdouglas (resteasy-reactive) |
geoand
added
triage/needs-reproducer
We are waiting for a reproducer.
and removed
env/windows
Impacts Windows machines
triage/needs-reproducer
We are waiting for a reproducer.
labels
Jul 24, 2023
As is mentioned in the Javadoc of Your working example does return new ObjectMapper().addMixIn(Buggy.class, NoTypes.class).writer(); while it's almost certainly best to do: return objectMapper.copy().addMixIn(Buggy.class, NoTypes.class).writer(); |
geoand
added a commit
to geoand/quarkus
that referenced
this issue
Jul 24, 2023
geoand
added a commit
to geoand/quarkus
that referenced
this issue
Jul 24, 2023
geoand
added a commit
that referenced
this issue
Jul 24, 2023
Improve Javadoc of @CustomSerialization
gsmet
pushed a commit
to gsmet/quarkus
that referenced
this issue
Jul 28, 2023
Relates to: quarkusio#34934 (cherry picked from commit b87954f)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
I have a REST method with the @CustomSerialization annotation.
According to the documentation I have implemented the static class with the apply method. This method has an ObjectMapper as the first parameter.
The problem is the objectMapper has to be reinstanciate each time the method is called.
Concretely :
The addMixIn call has no effect.
I must do like this to customize the objectMapper :
This is because somewhere else in the application I have this :
The bug comes from my object model. I have an interface (Buggy) and two classes that implement it (SimpleBug and ComplexeBug)
There is no problem to use the objectMapper with the SimpleBug class. But if use the objectMapper with the ComplexeBug class then I need to reinstanciate the ObjectMapper each time for my MixIn to be applied
Expected behavior
I don't have to reinstanciate the ObjectMapper class each time I want to use it.
The MixIn has been correctly applied.
Actual behavior
The objectMapper parameter of the
seems to be corrupted or I don't know what's wrong with it.
As a result the MixIn has no effect. The "class" field should not be there
I think the bug is tricky because of my object model. The SimpleBug class doesnt cause the bug. Only the ComplexeBug implementation. This is what I don t understand.
How to Reproduce?
bug.zip
Start the application :
1: mvn compile quarkus:dev -Dquarkus.http.port=8085
2: run that GET http method : http://localhost:8085/hello/bug
The response is buggy :
There is 3 ways to get around the bug :
1 :
In BuggyService, replace the line 27 :
by
2:
In BugResource line 46, replace the line
by
3 :
In BuggyService, replace the line 27 :
by
Then run the http GET request :
The MixIn has been applied but none of these 3 workaround is acceptable.
The MixIn should be applied without the need to reinstanciate the ObjectMapper (1 and 2) and with both SimpleBug and ComplexeBug classes. (3)
Output of
uname -a
orver
Windows 10
Output of
java -version
openjdk version "17" 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
GraalVM version (if different from Java)
N/A
Quarkus version or git rev
3.2.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Maven home: C:\dev\apache-maven-3.8.2
Additional information
I use lombok. May be you will need to install the plugin if you use and IDE
The text was updated successfully, but these errors were encountered: