From 7c7ec73305dc2be1d6acb9cb0b9f9e7fd62dccf3 Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Tue, 15 May 2018 15:06:12 +0200 Subject: Simplify allConfigServers() --- .../container/standalone/CloudConfigInstallVariables.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'standalone-container/src/main') 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 -- cgit v1.2.3