Skip to content

Commit

Permalink
Re-enable MutinyTest
Browse files Browse the repository at this point in the history
 - Fixes quarkusio#11687
 - Moved JAX-RS ClientBuilder service file for native to RESTClientProcessor
 - Use existing ResteasyProviderFactory to register client providers with if it exists, and don't replace the provider directly
  • Loading branch information
kenfinnigan committed Sep 2, 2020
1 parent 19f0f5b commit 892f0a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ void setupProviders(BuildProducer<NativeImageResourceBuildItem> resources,
resources.produce(new NativeImageResourceBuildItem(PROVIDERS_SERVICE_FILE));
}

@BuildStep
void setupClientBuilder(BuildProducer<NativeImageResourceBuildItem> resources) {
resources.produce(new NativeImageResourceBuildItem("META-INF/services/javax.ws.rs.client.ClientBuilder"));
}

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
BeanContainerListenerBuildItem fixExtension(RestClientRecorder restClientRecorder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> providersToRegister,
private static void registerProviders(ResteasyProviderFactory providerFactory, boolean useBuiltIn,
Set<String> providersToRegister,
Set<String> 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<String> providersToRegister,
Boolean isBuiltIn) {
for (String providerToRegister : providersToRegister) {
try {
clientProviderFactory
providerFactory
.registerProvider(Thread.currentThread().getContextClassLoader().loadClass(providerToRegister.trim()),
isBuiltIn);
} catch (ClassNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -164,8 +162,6 @@ public void build(
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy,
BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinition,
BuildProducer<NativeImageResourceBuildItem> resource,
BuildProducer<RuntimeInitializedClassBuildItem> runtimeClasses,
BuildProducer<BytecodeTransformerBuildItem> transformers,
BuildProducer<ResteasyServerConfigBuildItem> resteasyServerConfig,
BuildProducer<ResteasyDeploymentBuildItem> resteasyDeployment,
Expand All @@ -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<AnnotationInstance> applicationPaths = index.getAnnotations(ResteasyDotNames.APPLICATION_PATH);

// currently we only examine the first class that is annotated with @ApplicationPath so best
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 892f0a8

Please sign in to comment.