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

quarkus-resteasy-jsonb Marshaling Generic Type results in WARNINGS on each request #3538

Closed
avboy72 opened this issue Aug 15, 2019 · 10 comments · Fixed by #3557 or #6558
Closed

quarkus-resteasy-jsonb Marshaling Generic Type results in WARNINGS on each request #3538

avboy72 opened this issue Aug 15, 2019 · 10 comments · Fixed by #3557 or #6558
Assignees
Labels
kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Milestone

Comments

@avboy72
Copy link

avboy72 commented Aug 15, 2019

Using quarkus-resteasy-jsonb for my RESTful service

and with this class

public class MyEnvelopeClass<T> {
    private T content;

    public MyEnvelopeClass(T content) {
        this.content = content;
    }

    public T getContent() {
        return content;
    }
}

Returned from this resource method:

    @GET
    @Path("/{id}")
    public MyEnvelopeClass<MyPayloadClass> getById(@PathParam("id") String id){
        return new MyEnvelopeClass<MyPayloadClass>(new MyPayloadClass());
    }

The result from my GET request returns the correct payload, however, I get this warning in the log each time the request is made.

2019-08-15 12:25:36,477 WARNING [org.ecl.yas.int.ReflectionUtils] (executor-thread-1) Generic bound not found for type T declared in class MyEnvelopeClass.

If I switch to quarkus-resteasy-jackson, the warning is not logged. ( however I have to include other dependencies to get "Instant" to serialize properly, and configure the ObjectMapper to use it... Then I end up with Maven warnings too... so I would prefer to stick with the jsonb dependency )

If I change my code to use an anonymous inner class, extending MyEnvelopeClass with the Generic type... the warning is not logged:

    @GET
    @Path("/{id}")
    public MyEnvelopeClass<MyPayloadClass> getById(@PathParam("id") String id){
        return new MyEnvelopeClass<MyPayloadClass>(new MyPayloadClass()){};
    }

I can use this as a workaround, but I would rather fix the issue holistically rather than within every single Resource method we write.

Thanks!

-sean

Environment (please complete the following information):

  • Output of uname -a or ver:
    Darwin USMACEA013SSCOT 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64

  • Output of java -version:
    openjdk version "11.0.3" 2019-04-16
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

  • GraalVM version (if different from Java):
    openjdk version "1.8.0_222"
    OpenJDK Runtime Environment (build 1.8.0_222-20190711112007.graal.jdk8u-src-tar-gz-b08)
    OpenJDK 64-Bit GraalVM CE 19.1.1 (build 25.222-b08-jvmci-19.1-b01, mixed mode)

  • Quarkus version or git rev:
    <quarkus.version>0.20.0</quarkus.version>

@avboy72 avboy72 added the kind/bug Something isn't working label Aug 15, 2019
@sean-scott-lr
Copy link

Also, I just tried to run in Native mode. And neither option above produces output from my endpoint. just '''{}''' is returned

@sean-scott-lr
Copy link

sean-scott-lr commented Aug 15, 2019

More Information. Turns out the anonymous class is merely changing the behavior of what is being logged for the very first request after a hot-redeploy. ( Adding the {} makes the first request not get logged with a warning, but subsequent ones do )

So the anonymous class was just a red herring. I always get the warning.

@sean-scott-lr
Copy link

Adding @RegisterForReflection Fixed the issue with Native mode. Generics must not be supported in the Quarkus auto-registration?

So the only issue seems to be the noisy warning message

geoand added a commit to geoand/quarkus that referenced this issue Aug 18, 2019
This is needed when a JAX-RS resource returns a parameterized type that
is meant to be an enclosing class

Fixes: quarkusio#3538
@geoand
Copy link
Contributor

geoand commented Aug 18, 2019

I opened #3557 to handle the case you mentioned about needing @RegisterForReflection - that should not be necessary.

As for the log message, it is coming from Yasson, not sure what we could do about it.

geoand added a commit to geoand/quarkus that referenced this issue Aug 18, 2019
This is needed when a JAX-RS resource returns a parameterized type that
is meant to be an enclosing class

Fixes: quarkusio#3538
@gsmet
Copy link
Member

gsmet commented Aug 19, 2019

@geoand well, it could be a Yasson issue or a RESTEasy issue (with RESTEasy not providing the correct information to Yasson).

@sean-scott-lr could you try to reproduce the issue with simple Yasson code. If you can reproduce it then it's likely a Yasson issue and it should be reported here: https://github.com/eclipse-ee4j/yasson/issues

@sean-scott-lr
Copy link

sean-scott-lr commented Aug 19, 2019

@gsmet I will give it a shot, but this week will be tough because my schedule is packed.
...edit
Googled how to use the Yasson API, and it looked easy... so I went ahead and just added this to an endpoint that wasn't generating a warning.

            JsonbConfig config = new JsonbConfig() .withNullValues(false);
            Jsonb jsonb = JsonbBuilder.create(config);
            String result = jsonb.toJson(new MyEnvelopeClass<MyPayloadClass>(new MyPayloadClass()));
            System.out.println( result );

Yep, this bit of code generates the warning. I will open an issue on Yasson.

geoand added a commit to geoand/quarkus that referenced this issue Aug 19, 2019
This is needed when a JAX-RS resource returns a parameterized type that
is meant to be an enclosing class

Fixes: quarkusio#3538
gsmet added a commit that referenced this issue Aug 20, 2019
Register enclosing class for reflection when used as JAX-RS return type
aloubyansky pushed a commit to aloubyansky/quarkus that referenced this issue Aug 22, 2019
This is needed when a JAX-RS resource returns a parameterized type that
is meant to be an enclosing class

Fixes: quarkusio#3538
Dufgui pushed a commit to Dufgui/quarkus that referenced this issue Aug 26, 2019
This is needed when a JAX-RS resource returns a parameterized type that
is meant to be an enclosing class

Fixes: quarkusio#3538
@gsmet gsmet added this to the 0.22.0 milestone Aug 28, 2019
@aguibert
Copy link
Member

FYI I've delivered the fix for this issue in Yasson which will be included in the next release (1.0.6)

@gsmet gsmet added the triage/upstream Used for issues which are caused by issues in upstream projects/dependency label Nov 26, 2019
@gsmet gsmet removed this from the 0.23.0 milestone Nov 26, 2019
@gsmet gsmet reopened this Nov 28, 2019
@aguibert
Copy link
Member

@gsmet go ahead and assign this issue to me please. I can use it as a ticket to upgrade Quarkus to Yasson 1.0.6 when it gets released

@rsvoboda
Copy link
Member

@aguibert any idea when 1.0.6 will be released ?

@aguibert
Copy link
Member

@rsvoboda it's been a while since we released Yasson 1.0.5 so I suppose we're about due for a new release. I'll work on cutting a new Yasson release this week and getting Quarkus updated

@gsmet gsmet added this to the 1.2.0 milestone Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Projects
None yet
6 participants