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

Microprofile rest client - Can't inject config/beans to clientheaderfactory also in 1.4.2.Final #9301

Closed
Razsiel opened this issue May 14, 2020 · 5 comments · Fixed by #12009
Assignees
Labels
area/rest-client kind/bug Something isn't working
Milestone

Comments

@Razsiel
Copy link

Razsiel commented May 14, 2020

Describe the bug
In issue #7531 a solution was given for injecting providers in microprofile rest client using the annotations @RegisterProvider or @RegisterClientHeaders. Unfortunately the fix doesn't seem to work for @RegisterClientHeaders and my injected beans are always null.

Expected behavior
A class that implements ClientHeadersFactory and used in @RegisterClientHeaders annotation should have it's injectable beans injected.

Actual behavior
Any field marked with @Inject is always null. @RegisterProvider works as intended.

To Reproduce
Steps to reproduce the behavior:

  1. Clone project from marcinczeczko from @here (same as Microprofile rest client - Can't inject config/beans to providers also in 1.2.1.Final #7531)
  2. Update quarkus to 1.4.2.Final in the pom.xml (both plugin and platform properties)
  3. Start project and do GET request to localhost:8080/echo resource
  4. Check log to see that Provider has proper injection and the HeaderFactory does not

Configuration
Using properties from repo.

Screenshots
No screenshot, but a part of the log using above reproduction steps;

2020-05-14 15:54:41,126 INFO  [org.acm.res.MyHeadersFactory] (executor-thread-1) SomeBean = <null>
2020-05-14 15:54:41,126 INFO  [org.acm.res.MyHeadersFactory] (executor-thread-1) AppConfig = <null>
2020-05-14 15:54:41,126 INFO  [org.acm.res.RequestFilter] (executor-thread-1) SomeBean = <org.acme.restclient.SomeBean@75863ffd>
2020-05-14 15:54:41,127 INFO  [org.acm.res.RequestFilter] (executor-thread-1) AppConfig = <org.acme.restclient.AppConfig@7d71fc68>

Environment (please complete the following information):

  • Output of uname -a or ver: Linux garkenbout-laptop-quintor 5.0.0-38-generic Arc - implement CDI inheritance rules properly #41-Ubuntu SMP Tue Dec 3 00:27:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version: openjdk version "11.0.7" 2020-04-14
    OpenJDK Runtime Environment 18.9 (build 11.0.7+10)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10, mixed mode)
  • GraalVM version (if different from Java): didn't check
  • Quarkus version or git rev: 1.4.2.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
    Maven home: /home/garkenbout/.m2/wrapper/dists/apache-maven-3.6.2-bin/795eh28tki48bv3l67maojf0ra/apache-maven-3.6.2
    Java version: 11.0.7, vendor: Oracle Corporation, runtime: /home/garkenbout/.sdkman/candidates/java/11.0.7-open
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "5.0.0-38-generic", arch: "amd64", family: "unix"
@Razsiel Razsiel added the kind/bug Something isn't working label May 14, 2020
@Razsiel Razsiel changed the title Microprofile rest client - Can't inject config/beans to providers also in 1.4.2.Final Microprofile rest client - Can't inject config/beans to clientheaderfactory also in 1.4.2.Final May 14, 2020
@FatihErdem
Copy link

FatihErdem commented May 16, 2020

I have the exact same issue. I'm trying to add custom headers to a client and I want to get a property inside of a class that implements ClientHeadersFactory but until now, no luck.

@Razsiel
Copy link
Author

Razsiel commented May 20, 2020

I have found that adding @Provider above the class implementing ClientHeadersFactory seems to work, but this seems like a workaround. (This comment seems to back this statement.)

@famod
Copy link
Member

famod commented Sep 9, 2020

FTR: This is still a problem with 1.7.2.Final. My team also ran into this recently.

@mkouba & @phillip-kruger WDYT? Is this something that can be fixed?

@mkouba
Copy link
Contributor

mkouba commented Sep 9, 2020

Yes, we just need to handle the @RegisterClientHeaders annotations like we do for @RegisterProvider. I'll send a PR.

@mkouba mkouba self-assigned this Sep 9, 2020
@mkouba mkouba added this to the 1.9.0 - master milestone Sep 9, 2020
@famod
Copy link
Member

famod commented Sep 9, 2020

Awesome, thanks @mkouba!

mkouba added a commit to mkouba/quarkus that referenced this issue Sep 9, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Sep 9, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Sep 9, 2020
@gsmet gsmet modified the milestones: 1.9.0 - master, 1.8.1.Final Sep 17, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 17, 2020
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.

6 participants