don't double set settings with es.default. or elasticseearch.default.
though harmless, since we don't have any "default" component, and effectively has not effect on the settings used, it still puts settings that we don't really need
This commit is contained in:
parent
2e610ea653
commit
5533fe2b88
|
@ -655,7 +655,7 @@ public class ImmutableSettings implements Settings {
|
|||
/**
|
||||
* Puts all the properties with keys starting with the provided <tt>prefix</tt>.
|
||||
*
|
||||
* @param prefix The prefix to filter proeprty key by
|
||||
* @param prefix The prefix to filter property key by
|
||||
* @param properties The properties to put
|
||||
* @return The builder
|
||||
*/
|
||||
|
@ -670,6 +670,33 @@ public class ImmutableSettings implements Settings {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all the properties with keys starting with the provided <tt>prefix</tt>.
|
||||
*
|
||||
* @param prefix The prefix to filter property key by
|
||||
* @param properties The properties to put
|
||||
* @return The builder
|
||||
*/
|
||||
public Builder putProperties(String prefix, Properties properties, String[] ignorePrefixes) {
|
||||
for (Object key1 : properties.keySet()) {
|
||||
String key = (String) key1;
|
||||
String value = properties.getProperty(key);
|
||||
if (key.startsWith(prefix)) {
|
||||
boolean ignore = false;
|
||||
for (String ignorePrefix : ignorePrefixes) {
|
||||
if (key.startsWith(ignorePrefix)) {
|
||||
ignore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ignore) {
|
||||
map.put(key.substring(prefix.length()), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs across all the settings set on this builder and replaces <tt>${...}</tt> elements in the
|
||||
* each setting value according to the following logic:
|
||||
|
|
|
@ -36,13 +36,15 @@ import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilde
|
|||
public class InternalSettingsPerparer {
|
||||
|
||||
public static Tuple<Settings, Environment> prepareSettings(Settings pSettings, boolean loadConfigSettings) {
|
||||
// ignore this prefixes when getting properties from es. and elasticsearch.
|
||||
String[] ignorePrefixes = new String[]{"es.default.", "elasticsearch.default."};
|
||||
// just create enough settings to build the environment
|
||||
ImmutableSettings.Builder settingsBuilder = settingsBuilder()
|
||||
.put(pSettings)
|
||||
.putProperties("elasticsearch.default.", System.getProperties())
|
||||
.putProperties("es.default.", System.getProperties())
|
||||
.putProperties("elasticsearch.", System.getProperties())
|
||||
.putProperties("es.", System.getProperties())
|
||||
.putProperties("elasticsearch.", System.getProperties(), ignorePrefixes)
|
||||
.putProperties("es.", System.getProperties(), ignorePrefixes)
|
||||
.replacePropertyPlaceholders();
|
||||
|
||||
Environment environment = new Environment(settingsBuilder.build());
|
||||
|
@ -85,8 +87,8 @@ public class InternalSettingsPerparer {
|
|||
}
|
||||
|
||||
settingsBuilder.put(pSettings)
|
||||
.putProperties("elasticsearch.", System.getProperties())
|
||||
.putProperties("es.", System.getProperties())
|
||||
.putProperties("elasticsearch.", System.getProperties(), ignorePrefixes)
|
||||
.putProperties("es.", System.getProperties(), ignorePrefixes)
|
||||
.replacePropertyPlaceholders();
|
||||
|
||||
// generate the name
|
||||
|
|
Loading…
Reference in New Issue