diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java index ec77b1cd3e8..f2c0073775f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java @@ -235,7 +235,10 @@ public class ImmutableSettings implements Settings { List result = Lists.newArrayList(); if (get(settingPrefix) != null) { - Collections.addAll(result, Strings.commaDelimitedListToStringArray(get(settingPrefix))); + String[] strings = Strings.splitStringByCommaToArray(get(settingPrefix)); + if (strings.length > 0) { + Collections.addAll(result, strings); + } } int counter = 0; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 6acfadc308b..38ca638480f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -100,7 +100,12 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen this.transportService = transportService; this.clusterName = clusterName; - List hosts = Lists.newArrayList(componentSettings.getAsArray("hosts")); + String[] hostArr = componentSettings.getAsArray("hosts"); + // trim the hosts + for (int i = 0; i < hostArr.length; i++) { + hostArr[i] = hostArr[i].trim(); + } + List hosts = Lists.newArrayList(hostArr); logger.debug("using initial hosts {}", hosts); List nodes = Lists.newArrayList();