fix consul repeated invoker KVCache.newCache (#3833)

This commit is contained in:
zhang-wei 2019-11-11 22:26:21 +08:00 committed by 吴晟 Wu Sheng
parent f4e0f22193
commit c35c6f2a2e
1 changed files with 4 additions and 1 deletions

View File

@ -93,7 +93,10 @@ public class ConsulConfigurationWatcherRegister extends ConfigWatcherRegister {
}
private void registerKeyListeners(final Set<String> keys) {
keys.forEach(key -> {
final Set<String> unregisterKeys = new HashSet<>(keys);
unregisterKeys.removeAll(cachesByKey.keySet());
unregisterKeys.forEach(key -> {
KVCache cache = KVCache.newCache(consul, key);
cache.addListener(newValues -> {
Optional<Value> value = newValues.values().stream().filter(it -> key.equals(it.getKey())).findAny();