diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-05-15 15:06:12 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-05-15 15:06:12 +0200 |
commit | 7c7ec73305dc2be1d6acb9cb0b9f9e7fd62dccf3 (patch) | |
tree | a7bf5afd3d32d51bfdf0bbd48a9ac3e721fd7709 | |
parent | ed7e367e5ce82e208c4ecd29411a438449b85472 (diff) |
Simplify allConfigServers()
-rw-r--r-- | standalone-container/src/main/java/com/yahoo/container/standalone/CloudConfigInstallVariables.java | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/standalone-container/src/main/java/com/yahoo/container/standalone/CloudConfigInstallVariables.java b/standalone-container/src/main/java/com/yahoo/container/standalone/CloudConfigInstallVariables.java index 949e3bfd855..2b030656e29 100644 --- a/standalone-container/src/main/java/com/yahoo/container/standalone/CloudConfigInstallVariables.java +++ b/standalone-container/src/main/java/com/yahoo/container/standalone/CloudConfigInstallVariables.java @@ -25,15 +25,11 @@ public class CloudConfigInstallVariables implements CloudConfigOptions { @Override public ConfigServer[] allConfigServers() { - String newVar = System.getenv("VESPA_CONFIGSERVERS"); - if (newVar != null && !newVar.isEmpty()) { - return toConfigServers(newVar); - } - String oldVar = getRawInstallVariable("services.addr_configserver").orElse(null); - if (oldVar != null && !oldVar.isEmpty()) { - return toConfigServers(oldVar); - } - return new ConfigServer[0]; + return Optional.ofNullable(System.getenv("VESPA_CONFIGSERVERS")) + .map(Optional::of) // TODO Rewrite Optional.or() with Java 9 + .orElseGet(() -> getRawInstallVariable("services.addr_configserver")) + .map(CloudConfigInstallVariables::toConfigServers) + .orElseGet(() -> new ConfigServer[0]); } @Override |