Skip to content
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

JSON-B transient and property annotation collide #13640

Closed
sdaschner opened this issue Aug 25, 2020 · 1 comment · Fixed by #21574
Closed

JSON-B transient and property annotation collide #13640

sdaschner opened this issue Aug 25, 2020 · 1 comment · Fixed by #21574
Assignees
Labels
bug This bug is not present in a released version of Open Liberty Needs member attention team:Zombie Apocalypse

Comments

@sdaschner
Copy link

When mapping a class via JSON-B, and annotating fields as follows, the result throws an error because of mismatching types:

public class Coffee {

    @JsonbTransient
    private Order order;

    @JsonbProperty("order")
    private URI orderLink;

    Coffee() {
        order = new Order();
        orderLink = URI.create("http://localhost/");
    }

    // getters & setters
}

this results in:

[ERROR   ] Unable to serialize property 'order' from com.sebastian_daschner.openliberty.Coffee
[ERROR   ] Generating incomplete JSON
[ERROR   ] Problem with writing the data, class com.sebastian_daschner.openliberty.Coffee, ContentType: application/json

If both properties order and orderLink have the same type, it works as expected (i.e. orderLink is serialized as "order").

However, if we annotate @JsonbProperty on the setter instead, it works:

public class Coffee {

    @JsonbTransient
    private Order order;

    private URI orderLink;

    // [...]

    @JsonbProperty("order")
    public URI getOrderLink() {
        return orderLink;
    }

}

Response:

{"order":"http://localhost/"}

There seems to be an unexpected type link of the (ignored) property with the default serialized JSON key "order", and the custom name binding.

Tested with Open Liberty 20.0.0.8/wlp-1.0.43.cl200820200721-1900 on Eclipse OpenJ9 VM, version 14+36

@aguibert
Copy link
Contributor

This issue was also raised in Quarkus so I'm just going to track it at the source in Yasson here:
eclipse-ee4j/yasson#444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This bug is not present in a released version of Open Liberty Needs member attention team:Zombie Apocalypse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants