diff --git a/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java b/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java index c673933a9cb1c..cdf5a3d4afd36 100644 --- a/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java +++ b/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import jakarta.enterprise.context.SessionScoped; @@ -90,6 +91,7 @@ import io.quarkus.deployment.builditem.GeneratedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; +import io.quarkus.deployment.execannotations.ExecutionModelAnnotationsAllowedBuildItem; import io.quarkus.gizmo.ClassCreator; import io.quarkus.gizmo.MethodCreator; import io.quarkus.gizmo.MethodDescriptor; @@ -251,19 +253,16 @@ public void registerProvidersInstances(CombinedIndexBuildItem indexBuildItem, *
  • registers all the provider implementations annotated with @Provider using * {@link AnnotationRegisteredProviders#addGlobalProvider(Class, int)}
  • * - * - * - * @param indexBuildItem index - * @param generatedBeans build producer for generated beans */ @BuildStep void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem, List registerProviderAnnotationInstances, List annotationsToRegisterIntoClientContext, - BuildProducer generatedBeans, - BuildProducer generatedClasses, - BuildProducer unremovableBeans, - BuildProducer reflectiveClasses, + BuildProducer generatedBeansProducer, + BuildProducer generatedClassesProducer, + BuildProducer unremovableBeansProducer, + BuildProducer reflectiveClassesProducer, + BuildProducer executionModelAnnotationsAllowedProducer, RestClientReactiveConfig clientConfig) { String annotationRegisteredProvidersImpl = AnnotationRegisteredProviders.class.getName() + "Implementation"; IndexView index = indexBuildItem.getIndex(); @@ -276,7 +275,7 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem, try (ClassCreator classCreator = ClassCreator.builder() .className(annotationRegisteredProvidersImpl) - .classOutput(new GeneratedBeanGizmoAdaptor(generatedBeans)) + .classOutput(new GeneratedBeanGizmoAdaptor(generatedBeansProducer)) .superClass(AnnotationRegisteredProviders.class) .build()) { @@ -316,12 +315,13 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem, } MultivaluedMap generatedProviders = new QuarkusMultivaluedHashMap<>(); - populateClientExceptionMapperFromAnnotations(generatedClasses, reflectiveClasses, index) + populateClientExceptionMapperFromAnnotations(index, generatedClassesProducer, reflectiveClassesProducer, + executionModelAnnotationsAllowedProducer) .forEach(generatedProviders::add); - populateClientRedirectHandlerFromAnnotations(generatedClasses, reflectiveClasses, index) + populateClientRedirectHandlerFromAnnotations(generatedClassesProducer, reflectiveClassesProducer, index) .forEach(generatedProviders::add); for (AnnotationToRegisterIntoClientContextBuildItem annotation : annotationsToRegisterIntoClientContext) { - populateClientProviderFromAnnotations(annotation, generatedClasses, reflectiveClasses, index) + populateClientProviderFromAnnotations(annotation, generatedClassesProducer, reflectiveClassesProducer, index) .forEach(generatedProviders::add); } @@ -331,7 +331,7 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem, constructor.returnValue(null); } - unremovableBeans.produce(UnremovableBeanBuildItem.beanClassNames(annotationRegisteredProvidersImpl)); + unremovableBeansProducer.produce(UnremovableBeanBuildItem.beanClassNames(annotationRegisteredProvidersImpl)); } @BuildStep @@ -629,12 +629,22 @@ private boolean skipAutoDiscoveredProvider(List providerInterfaceNames) } private Map populateClientExceptionMapperFromAnnotations( - BuildProducer generatedClasses, - BuildProducer reflectiveClasses, IndexView index) { + IndexView index, + BuildProducer generatedClassesProducer, + BuildProducer reflectiveClassesProducer, + BuildProducer executionModelAnnotationsAllowedProducer) { + + executionModelAnnotationsAllowedProducer.produce(new ExecutionModelAnnotationsAllowedBuildItem( + new Predicate<>() { + @Override + public boolean test(MethodInfo methodInfo) { + return methodInfo.hasDeclaredAnnotation(CLIENT_EXCEPTION_MAPPER); + } + })); var result = new HashMap(); ClientExceptionMapperHandler clientExceptionMapperHandler = new ClientExceptionMapperHandler( - new GeneratedClassGizmoAdaptor(generatedClasses, true)); + new GeneratedClassGizmoAdaptor(generatedClassesProducer, true)); for (AnnotationInstance instance : index.getAnnotations(CLIENT_EXCEPTION_MAPPER)) { GeneratedClassResult classResult = clientExceptionMapperHandler.generateResponseExceptionMapper(instance); if (classResult == null) { @@ -645,7 +655,7 @@ private Map populateClientExceptionMapperFromAnnot + "' is allowed per REST Client interface. Offending class is '" + classResult.interfaceName + "'"); } result.put(classResult.interfaceName, classResult); - reflectiveClasses.produce(ReflectiveClassBuildItem.builder(classResult.generatedClassName) + reflectiveClassesProducer.produce(ReflectiveClassBuildItem.builder(classResult.generatedClassName) .serialization(false).build()); } return result;