diff --git a/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java b/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java index 98fe4d88..66739bba 100644 --- a/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java +++ b/config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java @@ -12,9 +12,10 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.function.Function; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -35,9 +36,9 @@ public class VaultConfigSource implements ConfigSource { private static final String PATHS_SEPARATOR = ":"; private final VaultInvoker vault; - private final List secretsPaths; + private final Collection secretsPaths; - private VaultConfigSource(VaultInvoker vault, List secretsPaths) { + private VaultConfigSource(VaultInvoker vault, Collection secretsPaths) { this.vault = vault; this.secretsPaths = new ArrayList<>(secretsPaths); } @@ -72,13 +73,14 @@ public static final class Builder { private VaultInvoker invoker; - private List secretsPaths = + private Set secretsPaths = Optional.ofNullable( Optional.ofNullable(ENVIRONMENT_LOADER.loadVariable("VAULT_SECRETS_PATH")) .orElse(ENVIRONMENT_LOADER.loadVariable("VAULT_SECRETS_PATHS"))) .map(s -> s.split(PATHS_SEPARATOR)) .map(Arrays::asList) - .orElseGet(ArrayList::new); + .map(HashSet::new) + .orElseGet(HashSet::new); private Builder() {} @@ -120,11 +122,10 @@ public Builder secretsPaths(Collection secretsPaths) { return this; } - private static List toSecretsPaths(Collection secretsPaths) { + private static Set toSecretsPaths(Collection secretsPaths) { return secretsPaths.stream() .flatMap(s -> Arrays.stream(s.split(PATHS_SEPARATOR))) - .distinct() - .collect(Collectors.toList()); + .collect(Collectors.toSet()); } public Builder invoker(VaultInvoker invoker) {