diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java index 22a4b76f9b69e..5f5a7c34939f2 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java @@ -9,6 +9,8 @@ import static io.quarkus.rest.client.reactive.deployment.DotNames.CLIENT_QUERY_PARAM; import static io.quarkus.rest.client.reactive.deployment.DotNames.CLIENT_QUERY_PARAMS; import static io.quarkus.rest.client.reactive.deployment.DotNames.CLIENT_REDIRECT_HANDLER; +import static io.quarkus.rest.client.reactive.deployment.DotNames.CLIENT_REQUEST_FILTER; +import static io.quarkus.rest.client.reactive.deployment.DotNames.CLIENT_RESPONSE_FILTER; import static io.quarkus.rest.client.reactive.deployment.DotNames.REGISTER_CLIENT_HEADERS; import static io.quarkus.rest.client.reactive.deployment.DotNames.REGISTER_PROVIDER; import static io.quarkus.rest.client.reactive.deployment.DotNames.REGISTER_PROVIDERS; @@ -297,18 +299,10 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem, } } - List providerInterfaceNames = providerClass.interfaceNames(); - // don't register server specific types - if (providerInterfaceNames.contains(ResteasyReactiveDotNames.CONTAINER_REQUEST_FILTER) - || providerInterfaceNames.contains(ResteasyReactiveDotNames.CONTAINER_RESPONSE_FILTER) - || providerInterfaceNames.contains(ResteasyReactiveDotNames.EXCEPTION_MAPPER)) { + if (skipAutoDiscoveredProvider(providerClass.interfaceNames())) { continue; } - if (providerInterfaceNames.contains(ResteasyReactiveDotNames.FEATURE)) { - continue; // features should not be automatically registered for the client, see javadoc for Feature - } - DotName providerDotName = providerClass.name(); int priority = getAnnotatedPriority(index, providerDotName.toString(), Priorities.USER); @@ -580,6 +574,29 @@ && isImplementorOf(index, target.asClass(), RESPONSE_EXCEPTION_MAPPER, Set.of(AP } } + /** + * Based on a list of interfaces implemented by @Provider class, determine if registration + * should be skipped or not. Server-specific types should be omitted unless implementation + * of a ClientRequestFilter exists on the same class explicitly. + * Features should always be omitted. + */ + private boolean skipAutoDiscoveredProvider(List providerInterfaceNames) { + if (providerInterfaceNames.contains(ResteasyReactiveDotNames.FEATURE)) { + return true; + } + if (providerInterfaceNames.contains(ResteasyReactiveDotNames.CONTAINER_REQUEST_FILTER) + || providerInterfaceNames.contains(ResteasyReactiveDotNames.CONTAINER_RESPONSE_FILTER) + || providerInterfaceNames.contains(ResteasyReactiveDotNames.EXCEPTION_MAPPER)) { + if (providerInterfaceNames.contains(CLIENT_REQUEST_FILTER) + || providerInterfaceNames.contains(CLIENT_RESPONSE_FILTER)) { + return false; + } else { + return true; + } + } + return false; + } + private Map populateClientExceptionMapperFromAnnotations( BuildProducer generatedClasses, BuildProducer reflectiveClasses, IndexView index) {