Unicast Discovery: When providing a comma separated list of addresses, trim them from whitespaces, closes #1193.

This commit is contained in:
Shay Banon 2011-08-02 13:42:38 +03:00
parent a0bbb5445a
commit 885c80f8e5
2 changed files with 10 additions and 2 deletions

View File

@ -235,7 +235,10 @@ public class ImmutableSettings implements Settings {
List<String> 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;

View File

@ -100,7 +100,12 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
this.transportService = transportService;
this.clusterName = clusterName;
List<String> 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<String> hosts = Lists.newArrayList(hostArr);
logger.debug("using initial hosts {}", hosts);
List<DiscoveryNode> nodes = Lists.newArrayList();