Skip to content

Commit

Permalink
Avoid possible concurrency issues with RestClientsConfig.RestClientKe…
Browse files Browse the repository at this point in the history
…ysProvider.KEYS in build time
  • Loading branch information
radcortez committed Nov 6, 2024
1 parent e124f18 commit c992add
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,29 @@
public abstract class AbstractRestClientConfigBuilder implements ConfigBuilder {
private static final String REST_CLIENT_PREFIX = "quarkus.rest-client.";

private final boolean runtime;

public AbstractRestClientConfigBuilder() {
this.runtime = true;
RestClientsConfig.RestClientKeysProvider.KEYS.clear();
}

public AbstractRestClientConfigBuilder(boolean runtime) {
this.runtime = runtime;
}

@Override
public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder) {
RestClientsConfig.RestClientKeysProvider.KEYS.clear();
List<RegisteredRestClient> restClients = getRestClients();

Map<String, String> quarkusFallbacks = new HashMap<>();
Map<String, String> microProfileFallbacks = new HashMap<>();
// relocates [All Combinations] -> quarkus.rest-client."FQN".*
Map<String, String> relocates = new HashMap<>();
for (RegisteredRestClient restClient : restClients) {
RestClientsConfig.RestClientKeysProvider.KEYS.add(restClient.getFullName());
if (runtime) {
RestClientsConfig.RestClientKeysProvider.KEYS.add(restClient.getFullName());
}

// FQN -> Simple Name
String quotedFullName = "\"" + restClient.getFullName() + "\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private ConfigSource getDefaultsSource() {
.withCustomizers(new SmallRyeConfigBuilderCustomizer() {
@Override
public void configBuilder(final SmallRyeConfigBuilder builder) {
new AbstractRestClientConfigBuilder() {
new AbstractRestClientConfigBuilder(false) {
@Override
public List<RegisteredRestClient> getRestClients() {
return restClients;
Expand Down

0 comments on commit c992add

Please sign in to comment.