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

BeanParam extending another class fails in RESTClient #21759

Closed
kjq opened this issue Nov 28, 2021 · 8 comments · Fixed by #21778
Closed

BeanParam extending another class fails in RESTClient #21759

kjq opened this issue Nov 28, 2021 · 8 comments · Fixed by #21778
Labels
area/rest-client kind/bug Something isn't working
Milestone

Comments

@kjq
Copy link

kjq commented Nov 28, 2021

Describe the bug

When a @BeanParam is used in a RESTClient and it extends another class it fails with the path param property not found.

Bad Request - Path parameter not provided client

If the class doe not extend another class or the properties are replicated in the extended class it will work fine.

beanparam.zip

Expected behavior

Classes can extend other classes and be used as @BeanParams.

Actual behavior

When the class extends another class it fails on the parents "properties" with "property not provided"

Non REST clients work find using the BeanParam if it extends another class.

Tried:

  • Public fields
  • Getters/Setters
  • Different Lombok annotations

The only thing that worked was to "replicate" the properties in each of the classes.

How to Reproduce?

Reproducer attached - running the tests demonstrate the issue.

There are two classes (BaseParam and MethodParams). You will get the below exception:

java.lang.IllegalArgumentException: Path parameter not provided base

Prior to modifying the old reproducer (for RESTClient does not support BeanParams), and without extending another class, the test passed.

Output of java -version

JDK 17

Quarkus version or git rev

2.5.0.Final

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

Maven 3.8.4 (with Lombok)

Additional information

I am still investigating this as well. Something is odd that I cannot pinpoint yet. I have other classes, used as @BeanParam that extend other classes, and they work as expected.

@kjq kjq added the kind/bug Something isn't working label Nov 28, 2021
@kjq
Copy link
Author

kjq commented Nov 28, 2021

I seem to recall having an issue before with the word client being used for some inference but I cannot find the reference. In my real codebase I am using @PathParam("client") but in my reproducer I do not.

@quarkus-bot
Copy link

quarkus-bot bot commented Nov 29, 2021

/cc @michalszynkiewicz

@geoand
Copy link
Contributor

geoand commented Nov 29, 2021

@Sgitario would you be interested in this one?

@Sgitario
Copy link
Contributor

Sure, will have a look asap

@geoand
Copy link
Contributor

geoand commented Nov 29, 2021

Thanks!

@Sgitario
Copy link
Contributor

@kjq just to clarify, in the reproducer, you have:

public static class BaseParams
    {
        @PathParam("base")
        private String base;

        // ...

    }

And:

public static class MethodParams
    {
        @PathParam("value")
        private String value;

        // ...
    }

Note that the MethodParams is missing the extends BaseParams.

I've confirmed that the path base is still not found even adding the extends BaseParams in your reproducer, which is the issue you reported. Can you confirm this?

Sgitario added a commit to Sgitario/quarkus that referenced this issue Nov 29, 2021
The method `ClassInfo.annotations` only returns the annotations at the current class level. 
This PR makes the parser method to also find the inherited annotations.
Fix quarkusio#21759
@kjq
Copy link
Author

kjq commented Nov 29, 2021 via email

@Sgitario
Copy link
Contributor

Hello Jose. Sorry about that, I don't know how I missed that. Yes, you are correct - that is the issue.

On Mon, Nov 29, 2021 at 6:45 AM Jose Carvajal @.***> wrote: @kjq https://github.com/kjq just to clarify, in the reproducer, you have: public static class BaseParams { @PathParam("base") private String base; // ... } And: public static class MethodParams { @PathParam("value") private String value; // ... } Note that the MethodParams is missing the extends BaseParams. I've confirmed that the path base is still not found even adding the extends BaseParams in your reproducer, which is the issue you reported. Can you confirm this? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#21759 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECKMWT54M3A3HIMY5M2DTUONRT7ANCNFSM5I5NONFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Ok, thanks for confirming. The linked pull request should address this issue.

@quarkus-bot quarkus-bot bot added this to the 2.6 - main milestone Nov 29, 2021
@gsmet gsmet modified the milestones: 2.6 - main, 2.5.1.Final Nov 30, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 30, 2021
The method `ClassInfo.annotations` only returns the annotations at the current class level.
This PR makes the parser method to also find the inherited annotations.
Fix quarkusio#21759

(cherry picked from commit b44601a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest-client kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants