quarkuseclipse-microprofile-config

Should I wrap @ConfigProperty fields in a javax.enterprise.inject.Instance object?


In my quarkus project I inject several ConfigProperty in filters (ContainerRequestFilter, ContainerResponseFilter). This gives me the following warning on startup:

[io.qua.res.com.dep.ResteasyCommonProcessor] (build-46) Directly injecting a @ConfigProperty into a JAX-RS provider may lead to unexpected results. To ensure proper results, please change the type of the field to javax.enterprise.inject.Instance<java.lang.String>. Offending field is 'fieldName' of class 'className'  

[io.qua.res.com.dep.ResteasyCommonProcessor] (build-46) Directly injecting a @ConfigProperty into a JAX-RS provider may lead to unexpected results. To ensure proper results, please change the type of the field to javax.enterprise.inject.Instance<java.util.List<java.lang.String>>. Offending field is 'fieldName' of class 'className'

However, the configuration guide never mentions this and even shows an example of injecting ConfigProperty in a JAX-RS resource.

Also, despite the warning, everything works fine. So my question is: should I care about this warning and apply its advice or can I ignore it ? Why is there no mention of this in the guides (neither the short one, nor the reference one)

I'm using quarkus 1.12.2 but I had the "issue" with previous versions too.


Solution

  • The warning is only shown for JAX-RS Providers, not JAX-RS Resources.

    I would suggest you do head the warning - but as I mentioned above only make the change for Providers (like the filters you mention)