Skip to content

Rest-client does not write all JSON fields when using both reflection-free serializer and deserializer #46458

@fedinskiy

Description

@fedinskiy

Describe the bug

I have an application, with several endpoints. First of them returns POJO class, and the second one accepts the same POJO as input. In both cases POJO is (de)serialized to/from JSON. The first one is called from REST client (in the same app), which makes the result accessible on the third endpoint.
When I enable the new reflection-free (de)serialization, client endpoint returns json with one of the fields set to null. This doesn't happen, when I remove the second endpoint.

Expected behavior

REST client should never lose data

Actual behavior

Original data:
{"author":"Heller","title":"Catch-22"}
Data, copied by REST client:
{"author":null,"title":"Catch-22"}

How to Reproduce?

  1. git clone -b client-serialize-field-null [email protected]:fedinskiy/reproducer.git & cd reproducer
  2. mvn clean verify This fails
  3. mvn clean verify -Dquarkus.rest.jackson.optimization.enable-reflection-free-serializers=false The old version succeeds
  4. If method sequel is removed from file src/main/java/io/quarkus/qe/GreetingResource.java, the test succeeds

If we compare these two versions (with and without sequel method), we can find difference in generated classes:

  1. mvn clean package -DskipTests -Dquarkus.package.jar.decompiler.enabled=true
  2. ls target/decompiler/generated-bytecode/io/quarkus/qe/ | grep quarkusjackson
    The failing version contains deserializer class:
Book$quarkusjacksondeserializer.java
Book$quarkusjacksonserializer.java
SerializedStrings$quarkusjacksonserializer.java

and the working one doesn't

Book$quarkusjacksonserializer.java
SerializedStrings$quarkusjacksonserializer.java

Output of uname -a or ver

6.12.15-200.fc41.x86_64

Output of java -version

21.0.5, vendor: Eclipse Adoptium

Quarkus version or git rev

3.18.4

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions