You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Class structures that contain a recursive reference can't be mapped to JSON, even though when one defines custom JSON-B serializers or type adapters. This doesn't really make sense, since serializing (back) references to, for example, scalar values stops the recursion.
Expected behavior
Make it possible to serialize recursive references when custom serializers / type adapters are present.
This will cause Quarkus to throw an exception like:
Caused by: jakarta.json.bind.JsonbException: Unable to serialize property 'schedule' from com.sebastian_daschner.coffee.JsonTestResource.Item
at org.eclipse.yasson.internal.serializer.ObjectSerializer.lambda$serialize$0(ObjectSerializer.java:43)
[...]
at org.eclipse.yasson.internal.serializer.ObjectSerializer.lambda$serialize$0(ObjectSerializer.java:41)
... 25 more
Caused by: jakarta.json.bind.JsonbException: Recursive reference has been found in class class com.sebastian_daschner.coffee.JsonTestResource$Schedule.
at org.eclipse.yasson.internal.serializer.RecursionChecker.serialize(RecursionChecker.java:36)
[...]
As you can see in the code (Schedule -> Item), the back reference Item#schedule is annotated with @JsonbTypeSerializer(ScheduleNameSerializer.class). Only if also the reference Schedule#item is annotated with a similar serializer, it works. Adding @JsonbTransient on the back reference also works.
However, the following output would be expected from that test:
Describe the bug
Class structures that contain a recursive reference can't be mapped to JSON, even though when one defines custom JSON-B serializers or type adapters. This doesn't really make sense, since serializing (back) references to, for example, scalar values stops the recursion.
Expected behavior
Make it possible to serialize recursive references when custom serializers / type adapters are present.
Actual behavior
No response
How to Reproduce?
Reproducer here: https://github.com/sdaschner/quarkus-playground/releases/tag/jsonb-recursive-mapping
(or run
JsonIT
in the project)This will cause Quarkus to throw an exception like:
As you can see in the code (
Schedule
->Item
), the back referenceItem#schedule
is annotated with@JsonbTypeSerializer(ScheduleNameSerializer.class)
. Only if also the referenceSchedule#item
is annotated with a similar serializer, it works. Adding@JsonbTransient
on the back reference also works.However, the following output would be expected from that test:
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
3.13.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: