Skip to content

Commit

Permalink
Merge pull request #2684 from gsmet/fix-provider-registration
Browse files Browse the repository at this point in the history
Only register the contributed providers if we use all the built-in ones
  • Loading branch information
mkouba authored Jun 3, 2019
2 parents 61dd7e9 + f7cd967 commit 2f60ce3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void registerProviders(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndexBuildItem,
SmallRyeRestClientTemplate smallRyeRestClientTemplate) {
smallRyeRestClientTemplate.initializeResteasyProviderFactory(jaxrsProvidersToRegisterBuildItem.useBuiltIn(),
jaxrsProvidersToRegisterBuildItem.getProviders());
jaxrsProvidersToRegisterBuildItem.getProviders(), jaxrsProvidersToRegisterBuildItem.getContributedProviders());

// register the providers for reflection
for (String providerToRegister : jaxrsProvidersToRegisterBuildItem.getProviders()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void setSslEnabled(boolean sslEnabled) {
RestClientBuilderImpl.SSL_ENABLED = sslEnabled;
}

public void initializeResteasyProviderFactory(boolean useBuiltIn, Set<String> providersToRegister) {
public void initializeResteasyProviderFactory(boolean useBuiltIn, Set<String> providersToRegister,
Set<String> contributedProviders) {
ResteasyProviderFactory clientProviderFactory = new ResteasyProviderFactoryImpl(null, true) {
@Override
public RuntimeType getRuntimeType() {
Expand All @@ -55,8 +56,15 @@ protected void initializeUtils() {

if (useBuiltIn) {
RegisterBuiltin.register(clientProviderFactory);
registerProviders(clientProviderFactory, contributedProviders);
} else {
registerProviders(clientProviderFactory, providersToRegister);
}

RestClientBuilderImpl.PROVIDER_FACTORY = clientProviderFactory;
}

private static void registerProviders(ResteasyProviderFactory clientProviderFactory, Set<String> providersToRegister) {
for (String providerToRegister : providersToRegister) {
try {
clientProviderFactory
Expand All @@ -65,7 +73,5 @@ protected void initializeUtils() {
throw new RuntimeException("Unable to find class for provider " + providerToRegister, e);
}
}

RestClientBuilderImpl.PROVIDER_FACTORY = clientProviderFactory;
}
}

0 comments on commit 2f60ce3

Please sign in to comment.