未验证 提交 782fb40e 编写于 作者: E elandau 提交者: GitHub

Merge pull request #424 from elandau/bugfix/default_config

config: Ensure dynamic config is always loaded for defaults
...@@ -34,7 +34,8 @@ public interface ClientConfigFactory { ...@@ -34,7 +34,8 @@ public interface ClientConfigFactory {
return StreamSupport.stream(ServiceLoader.load(ClientConfigFactory.class).spliterator(), false) return StreamSupport.stream(ServiceLoader.load(ClientConfigFactory.class).spliterator(), false)
.sorted(Comparator .sorted(Comparator
.comparingInt(ClientConfigFactory::getPriority) .comparingInt(ClientConfigFactory::getPriority)
.thenComparing(Comparator.comparing(f -> f.getClass().getCanonicalName()))) .thenComparing(f -> f.getClass().getCanonicalName())
.reversed())
.findFirst() .findFirst()
.orElseGet(() -> { .orElseGet(() -> {
throw new IllegalStateException("Expecting at least one implementation of ClientConfigFactory discoverable via the ServiceLoader"); throw new IllegalStateException("Expecting at least one implementation of ClientConfigFactory discoverable via the ServiceLoader");
......
...@@ -393,15 +393,13 @@ public abstract class ReloadableClientConfig implements IClientConfig { ...@@ -393,15 +393,13 @@ public abstract class ReloadableClientConfig implements IClientConfig {
public final <T> IClientConfig set(IClientConfigKey<T> key, T value) { public final <T> IClientConfig set(IClientConfigKey<T> key, T value) {
Preconditions.checkArgument(key != null, "key cannot be null"); 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); value = resolveValueToType(key, value);
// If a client is already specified then check if there's a dynamic config override available // Check if there's a dynamic config override available
if (isLoaded) {
value = resolveFinalProperty(key).orElse(value); value = resolveFinalProperty(key).orElse(value);
}
// Cache this new state // Cache the new value
internalProperties.put(key, Optional.ofNullable(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 // If this is the first time a property is seen and a client name has been specified then make sure
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册