Skip to content

Commit

Permalink
Merge pull request #424 from elandau/bugfix/default_config
Browse files Browse the repository at this point in the history
config: Ensure dynamic config is always loaded for defaults
  • Loading branch information
elandau committed May 22, 2019
2 parents 2a6e2e5 + a62f5a9 commit 782fb40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ static ClientConfigFactory findDefaultConfigFactory() {
return StreamSupport.stream(ServiceLoader.load(ClientConfigFactory.class).spliterator(), false)
.sorted(Comparator
.comparingInt(ClientConfigFactory::getPriority)
.thenComparing(Comparator.comparing(f -> f.getClass().getCanonicalName())))
.thenComparing(f -> f.getClass().getCanonicalName())
.reversed())
.findFirst()
.orElseGet(() -> {
throw new IllegalStateException("Expecting at least one implementation of ClientConfigFactory discoverable via the ServiceLoader");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,13 @@ public final <T> T get(IClientConfigKey<T> key, T defaultValue) {
public final <T> IClientConfig set(IClientConfigKey<T> key, T value) {
Preconditions.checkArgument(key != null, "key cannot be null");

// Make sure the value is property typed
// Make sure the value is property typed.
value = resolveValueToType(key, value);

// If a client is already specified then check if there's a dynamic config override available
if (isLoaded) {
value = resolveFinalProperty(key).orElse(value);
}
// Check if there's a dynamic config override available
value = resolveFinalProperty(key).orElse(value);

// Cache this new state
// Cache the new value
internalProperties.put(key, Optional.ofNullable(value));

// If this is the first time a property is seen and a client name has been specified then make sure
Expand Down

0 comments on commit 782fb40

Please sign in to comment.