diff --git a/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java b/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java index 246a0dfc2611a..0312f8ca1372c 100644 --- a/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java +++ b/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java @@ -104,6 +104,11 @@ void setupProviders(BuildProducer resources, resources.produce(new NativeImageResourceBuildItem(PROVIDERS_SERVICE_FILE)); } + @BuildStep + void setupClientBuilder(BuildProducer resources) { + resources.produce(new NativeImageResourceBuildItem("META-INF/services/javax.ws.rs.client.ClientBuilder")); + } + @Record(ExecutionTime.STATIC_INIT) @BuildStep BeanContainerListenerBuildItem fixExtension(RestClientRecorder restClientRecorder) { diff --git a/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java b/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java index 3126e543e5455..1b68d8c594f72 100644 --- a/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java +++ b/extensions/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientRecorder.java @@ -59,25 +59,36 @@ public InjectorFactory getInjectorFactory() { } }; - if (useBuiltIn) { - RegisterBuiltin.register(clientProviderFactory); - registerProviders(clientProviderFactory, contributedProviders, false); + registerProviders(clientProviderFactory, useBuiltIn, providersToRegister, contributedProviders); + + if (ResteasyProviderFactory.peekInstance() != null) { + ResteasyProviderFactory serverProviderFactory = ResteasyProviderFactory.getInstance(); + registerProviders(serverProviderFactory, useBuiltIn, providersToRegister, contributedProviders); } else { - providersToRegister.removeAll(contributedProviders); - registerProviders(clientProviderFactory, providersToRegister, true); - registerProviders(clientProviderFactory, contributedProviders, false); + ResteasyProviderFactory.setInstance(clientProviderFactory); } RestClientBuilderImpl.setProviderFactory(clientProviderFactory); - ResteasyProviderFactory.setInstance(clientProviderFactory); providerFactory = clientProviderFactory; } - private static void registerProviders(ResteasyProviderFactory clientProviderFactory, Set providersToRegister, + private static void registerProviders(ResteasyProviderFactory providerFactory, boolean useBuiltIn, + Set providersToRegister, + Set contributedProviders) { + if (useBuiltIn) { + RegisterBuiltin.register(providerFactory); + } else { + providersToRegister.removeAll(contributedProviders); + registerProviders(providerFactory, providersToRegister, true); + } + registerProviders(providerFactory, contributedProviders, false); + } + + private static void registerProviders(ResteasyProviderFactory providerFactory, Set providersToRegister, Boolean isBuiltIn) { for (String providerToRegister : providersToRegister) { try { - clientProviderFactory + providerFactory .registerProvider(Thread.currentThread().getContextClassLoader().loadClass(providerToRegister.trim()), isBuiltIn); } catch (ClassNotFoundException e) { diff --git a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java index 04ee03c83b483..cd20f81dcada6 100755 --- a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java +++ b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java @@ -61,10 +61,8 @@ import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; -import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem; -import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.gizmo.Gizmo; import io.quarkus.resteasy.common.deployment.JaxrsProvidersToRegisterBuildItem; import io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor.ResteasyCommonConfig; @@ -164,8 +162,6 @@ public void build( BuildProducer reflectiveClass, BuildProducer reflectiveHierarchy, BuildProducer proxyDefinition, - BuildProducer resource, - BuildProducer runtimeClasses, BuildProducer transformers, BuildProducer resteasyServerConfig, BuildProducer resteasyDeployment, @@ -184,8 +180,6 @@ public void build( CustomScopeAnnotationsBuildItem scopes) throws Exception { IndexView index = combinedIndexBuildItem.getIndex(); - resource.produce(new NativeImageResourceBuildItem("META-INF/services/javax.ws.rs.client.ClientBuilder")); - Collection applicationPaths = index.getAnnotations(ResteasyDotNames.APPLICATION_PATH); // currently we only examine the first class that is annotated with @ApplicationPath so best diff --git a/integration-tests/resteasy-mutiny/src/test/java/io/quarkus/it/resteasy/mutiny/MutinyTest.java b/integration-tests/resteasy-mutiny/src/test/java/io/quarkus/it/resteasy/mutiny/MutinyTest.java index 165c19d7b314a..5f3d3f17bcd67 100644 --- a/integration-tests/resteasy-mutiny/src/test/java/io/quarkus/it/resteasy/mutiny/MutinyTest.java +++ b/integration-tests/resteasy-mutiny/src/test/java/io/quarkus/it/resteasy/mutiny/MutinyTest.java @@ -15,7 +15,6 @@ import javax.ws.rs.sse.SseEventSource; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; @@ -83,7 +82,6 @@ public void testMultiWithSerialization() { } @Test - @Disabled("https://github.com/quarkusio/quarkus/issues/11687") public void testSSE() { Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:" + RestAssured.port + "/mutiny/pets");