diff --git a/extensions/resteasy-classic/rest-client-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientsBuildTimeConfig.java b/extensions/resteasy-classic/rest-client-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientsBuildTimeConfig.java index e4caffdc8453f..f3aa7ead6abe7 100644 --- a/extensions/resteasy-classic/rest-client-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientsBuildTimeConfig.java +++ b/extensions/resteasy-classic/rest-client-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientsBuildTimeConfig.java @@ -83,10 +83,15 @@ interface RestClientBuildConfig { * @return a {@link RestClientsBuildTimeConfig} with the discovered registered REST Clients configuration only. */ default RestClientsBuildTimeConfig get(List restClients) { - SmallRyeConfig config = new SmallRyeConfigBuilder() + return getConfig(restClients).getConfigMapping(RestClientsBuildTimeConfig.class); + } + + default SmallRyeConfig getConfig(List restClients) { + return new SmallRyeConfigBuilder() .withSources( new ConfigSource() { final SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class); + final ConfigSource defaultsSource = getDefaultsSource(); @Override public Set getPropertyNames() { @@ -97,13 +102,25 @@ public Set getPropertyNames() { @Override public String getValue(final String propertyName) { - return config.getRawValue(propertyName); + ConfigValue configValue = config.getConfigValue(propertyName); + if (configValue != null && !defaultsSource.getName().equals(configValue.getSourceName())) { + return configValue.getValue(); + } + return null; } @Override public String getName() { return "SmallRye Config"; } + + private ConfigSource getDefaultsSource() { + ConfigSource configSource = null; + for (ConfigSource source : config.getConfigSources()) { + configSource = source; + } + return configSource; + } }) .withCustomizers(new SmallRyeConfigBuilderCustomizer() { @Override @@ -119,7 +136,5 @@ public List getRestClients() { .withMapping(RestClientsBuildTimeConfig.class) .withMappingIgnore("quarkus.**") .build(); - - return config.getConfigMapping(RestClientsBuildTimeConfig.class); } } diff --git a/extensions/resteasy-classic/rest-client-config/runtime/src/test/java/io/quarkus/restclient/config/RestClientConfigTest.java b/extensions/resteasy-classic/rest-client-config/runtime/src/test/java/io/quarkus/restclient/config/RestClientConfigTest.java index 8476badf6a4d2..2a8c2621726c5 100644 --- a/extensions/resteasy-classic/rest-client-config/runtime/src/test/java/io/quarkus/restclient/config/RestClientConfigTest.java +++ b/extensions/resteasy-classic/rest-client-config/runtime/src/test/java/io/quarkus/restclient/config/RestClientConfigTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -232,6 +233,19 @@ public List getRestClients() { assertThat(restClientConfig.uri().get()).isEqualTo("http://localhost:8082"); } + @Test + void buildTimeConfig() { + SmallRyeConfig config = ConfigUtils.emptyConfigBuilder() + .withMapping(RestClientsBuildTimeConfig.class) + .build(); + assertNotNull(config); + + RestClientsBuildTimeConfig buildTimeConfig = config.getConfigMapping(RestClientsBuildTimeConfig.class) + .get(List.of(new RegisteredRestClient(ConfigKeyRestClient.class, "key"))); + + assertFalse(buildTimeConfig.clients().get(ConfigKeyRestClient.class.getName()).removesTrailingSlash()); + } + private void verifyConfig(RestClientConfig config) { assertTrue(config.url().isPresent()); assertThat(config.url().get()).isEqualTo("http://localhost:8080"); diff --git a/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/devservices/DevServicesRestClientHttpProxyProcessor.java b/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/devservices/DevServicesRestClientHttpProxyProcessor.java index 913697d6af206..6e2eb61e3f12c 100644 --- a/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/devservices/DevServicesRestClientHttpProxyProcessor.java +++ b/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/devservices/DevServicesRestClientHttpProxyProcessor.java @@ -17,7 +17,6 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.exception.UncheckedException; -import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.IndexView; import org.jboss.logging.Logger; @@ -32,6 +31,7 @@ import io.quarkus.rest.client.reactive.deployment.RegisteredRestClientBuildItem; import io.quarkus.rest.client.reactive.spi.DevServicesRestClientProxyProvider; import io.quarkus.rest.client.reactive.spi.RestClientHttpProxyBuildItem; +import io.quarkus.restclient.config.RegisteredRestClient; import io.quarkus.restclient.config.RestClientsBuildTimeConfig; import io.quarkus.restclient.config.RestClientsBuildTimeConfig.RestClientBuildConfig; import io.smallrye.config.SmallRyeConfig; @@ -60,14 +60,15 @@ public void determineRequiredProxies( CombinedIndexBuildItem combinedIndexBuildItem, List registeredRestClientBuildItems, BuildProducer producer) { - Map configs = clientsConfig.get(toRegisteredRestClients(registeredRestClientBuildItems)) - .clients(); + + List registeredRestClients = toRegisteredRestClients(registeredRestClientBuildItems); + Map configs = clientsConfig.get(registeredRestClients).clients(); if (configs.isEmpty()) { return; } IndexView index = combinedIndexBuildItem.getIndex(); - SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class); + SmallRyeConfig config = clientsConfig.getConfig(registeredRestClients); for (var configEntry : configs.entrySet()) { if (!configEntry.getValue().enableLocalProxy()) { log.trace("Ignoring config key: '" + configEntry.getKey() + "' because enableLocalProxy is false");