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

Reactive REST Client: check for ClientRequestFilter when skipping @Provider auto-discovery #37268

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -297,18 +299,10 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem,
}
}

List<DotName> 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);

Expand Down Expand Up @@ -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 <code>ClientRequestFilter</code> exists on the same class explicitly.
* Features should always be omitted.
*/
private boolean skipAutoDiscoveredProvider(List<DotName> 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<String, GeneratedClassResult> populateClientExceptionMapperFromAnnotations(
BuildProducer<GeneratedClassBuildItem> generatedClasses,
BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, IndexView index) {
Expand Down
Loading