Repository: quarkusio/quarkus
Issue: "Directly injecting a ConfigProperty into a javax.ws.rs.ext.Provider may lead to unexpected results" warning for OidcClientRequestFilter in Quarkus 2.12

### Describe the bug

Starting my app (in dev mode) logs the following message three times:
> 2022-08-24 21:07:54,704 WARN  [io.qua.arc.dep.ConfigBuildStep] (build-37) Directly injecting a org.eclipse.microprofile.config.inject.ConfigProperty into a javax.ws.rs.ext.Provider may lead to unexpected results. To ensure proper results, please change the type of the field to javax.enterprise.inject.Instance<java.util.Optional>. Offending field is 'clientName' of class 'io.quarkus.oidc.client.filter.OidcClientRequestFilter'

This wasn't there in 2.11.

Btw, we have two subclasses of that filter, e.g.:
```java
/**
 * Filter that configures using {@code foobar} {@link NamedOidcClient} for accessing a rest api.
 *
 * @see <a href="https://github.com/quarkusio/quarkus/issues/16397">Quarkus: Enhance OidcClientFilter to select named OIDC clients</a>
 */
public class FoobarOidcClientRequestFilter extends OidcClientRequestFilter {

    @Override
    protected Optional<String> clientId() {
        return Optional.of("foobar"); // has to match configured oidc-client id
    }
}
```

### Expected behavior

No such warning

### Actual behavior

Warning pointing to Quarkus code (not even my own one)

### How to Reproduce?

n/a for now

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.12.0.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Maven 3.8.6

### Additional information

_No response_

Changed files:
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java
integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java
extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java
extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java
extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java

diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java
index 7f8461e8e8a..2f2bf5cc46b 100644
--- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java
+++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java
@@ -177,6 +177,7 @@ void validateConfigInjectionPoints(ValidationPhaseBuildItem validationPhase,
                         || DotNames.OPTIONAL_INT.equals(injectedType.name())
                         || DotNames.OPTIONAL_LONG.equals(injectedType.name())
                         || DotNames.OPTIONAL_DOUBLE.equals(injectedType.name())
+                        || DotNames.INSTANCE.equals(injectedType.name())
                         || DotNames.PROVIDER.equals(injectedType.name())
                         || SUPPLIER_NAME.equals(injectedType.name())
                         || SR_CONFIG_VALUE_NAME.equals(injectedType.name())
diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java
index fa93fe79baf..f470551e44d 100644
--- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java
+++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java
@@ -9,7 +9,9 @@
 import java.util.OptionalInt;
 import java.util.OptionalLong;
 
+import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
+import javax.inject.Provider;
 import javax.inject.Singleton;
 
 import org.eclipse.microprofile.config.inject.ConfigProperty;
@@ -56,6 +58,9 @@ public void testOptionals() {
         assertFalse(usingOptionals.missingOptionalInt.isPresent());
         assertFalse(usingOptionals.missingOptionalLong.isPresent());
         assertFalse(usingOptionals.missingOptionalDouble.isPresent());
+
+        assertFalse(usingOptionals.instanceOptional.get().isPresent());
+        assertFalse(usingOptionals.providerOptional.get().isPresent());
     }
 
     @Singleton
@@ -107,6 +112,13 @@ static class UsingOptionals {
         @Inject
         @ConfigProperty(name = "missing")
         OptionalDouble missingOptionalDouble;
-    }
 
+        @Inject
+        @ConfigProperty(name = "missing")
+        Instance<Optional<String>> instanceOptional;
+
+        @Inject
+        @ConfigProperty(name = "missing")
+        Provider<Optional<String>> providerOptional;
+    }
 }
diff --git a/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java b/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java
index 2c982efd17a..5da589248d3 100644
--- a/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java
+++ b/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java
@@ -13,9 +13,9 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.Provider;
 
-import org.eclipse.microprofile.config.inject.ConfigProperty;
 import org.jboss.logging.Logger;
 
+import io.quarkus.oidc.client.filter.runtime.OidcClientFilterConfig;
 import io.quarkus.oidc.client.runtime.AbstractTokensProducer;
 import io.quarkus.oidc.client.runtime.DisabledOidcClientException;
 import io.quarkus.oidc.common.runtime.OidcConstants;
@@ -26,10 +26,8 @@
 public class OidcClientRequestFilter extends AbstractTokensProducer implements ClientRequestFilter {
     private static final Logger LOG = Logger.getLogger(OidcClientRequestFilter.class);
     private static final String BEARER_SCHEME_WITH_SPACE = OidcConstants.BEARER_SCHEME + " ";
-
     @Inject
-    @ConfigProperty(name = "quarkus.oidc-client-filter.client-name")
-    Optional<String> clientName;
+    OidcClientFilterConfig oidcClientFilterConfig;
 
     @Override
     public void filter(ClientRequestContext requestContext) throws IOException {
@@ -50,6 +48,6 @@ private String getAccessToken() {
     }
 
     protected Optional<String> clientId() {
-        return clientName;
+        return oidcClientFilterConfig.clientName;
     }
 }
diff --git a/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java b/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java
index 8c8f22f025d..420fefbce27 100644
--- a/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java
+++ b/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java
@@ -4,6 +4,7 @@
 
 import java.io.IOException;
 
+import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -56,11 +57,11 @@ public String hello(@Context HttpRequest request) {
     @Provider
     public static class MappingFilter implements ContainerRequestFilter {
         @Inject
-        Mapping mapping;
+        Instance<Mapping> mapping;
 
         @Override
         public void filter(final ContainerRequestContext requestContext) throws IOException {
-            requestContext.setProperty("mapping.hello", mapping.hello());
+            requestContext.setProperty("mapping.hello", mapping.get().hello());
         }
     }
 
diff --git a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java
index 8a1e5132fd9..b38f6a77f6c 100644
--- a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java
+++ b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java
@@ -1,5 +1,6 @@
 package io.quarkus.it.smallrye.config;
 
+import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -12,17 +13,17 @@
         implements ExceptionMapper<ConfigurableExceptionMapper.ConfigurableExceptionMapperException> {
     @Inject
     @ConfigProperty(name = "exception.message")
-    String message;
+    Instance<String> message;
     @Inject
-    ExceptionConfig exceptionConfig;
+    Instance<ExceptionConfig> exceptionConfig;
 
     @Override
     public Response toResponse(final ConfigurableExceptionMapperException exception) {
-        if (!message.equals(exceptionConfig.message())) {
+        if (!message.get().equals(exceptionConfig.get().message())) {
             return Response.serverError().build();
         }
 
-        return Response.ok().entity(message).build();
+        return Response.ok().entity(message.get()).build();
     }
 
     public static class ConfigurableExceptionMapperException extends RuntimeException {