quarkus: Microprofile rest client - Can't inject config/beans to providers
Describe the bug
Any provider added to rest client via @Provider annotation is unable to inject config bean or any other application scoped bean.
@RegisterRestClient
@RegisterProvider(RequestFilter.class)
public interface EchoService {....}
And example the provider impl:
public class RequestFilter implements ClientRequestFilter {
@Inject
AppConfig config; //is always null
@Inject
SomeBean bean; //is always null
@Override
public void filter(ClientRequestContext requestContext) throws IOException {...}
Expected behavior Config or application scope bean injected and not null
Actual behavior
Any bean injected via @Inject is alway null (no errors in logs during argumentation nor during runtime.
To Reproduce Steps to reproduce the behavior:
- Use reproducer: https://github.com/marcinczeczko/quarkus-rest-providers-reproducer
mvn compile quarkus:devcurl http://localhost:8080/echo- Check the logs - the injected config & app bean shows
nullreference
Configuration
- See reproducer
Screenshots N/A
Environment (please complete the following information):
- Output of
uname -aorver:18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64 - Output of
java -version:
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)
- GraalVM version (if different from Java): Didn’t check on graalvm
- Quarkus version or git rev: 1.0.0.Final
Additional context
I found out there is a closed issue for similar problem, but looks like the fix doesn’t work, see: https://github.com/quarkusio/quarkus/issues/2773
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 22 (21 by maintainers)
Commits related to this issue
- Rest Client - support injection for providers used in @RegisterProvider - i.e. for providers not annotated with @Provider - resolves #7531 - follows up on #5752 — committed to mkouba/quarkus by mkouba 4 years ago
- Rest Client - support injection for providers used in @RegisterProvider - i.e. for providers not annotated with @Provider - resolves #7531 - follows up on #5752 — committed to mkouba/quarkus by mkouba 4 years ago
@sassko can you open a new issue with your reproducer linked? Thanks!
4.4.2.Final is released
I’m not yet sure of when we will be able to release given all the problems we have.
But I’m not sure either if RESTEasy 4.5.0.Final will be an easy upgrade.
So I would say: release it, prepare a PR and we’ll see how it goes 😃.
@mkouba sure, I’ll most likely get to it this week