diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java index 3fcfdc08722..1c9aad322c8 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java @@ -47,6 +47,9 @@ public class DiscoveryNodeFilters { Map settingsMap = settings.getAsMap(); for (Map.Entry entry : settingsMap.entrySet()) { String propertyKey = entry.getKey(); + if (entry.getValue() == null) { + continue; // this setting gets reset + } if ("_ip".equals(propertyKey) || "_host_ip".equals(propertyKey) || "_publish_ip".equals(propertyKey)) { for (String value : Strings.tokenizeToStringArray(entry.getValue(), ",")) { if (InetAddresses.isInetAddress(value) == false) { diff --git a/core/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java b/core/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java index 01ace21ad12..dd96acdd6c7 100644 --- a/core/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java @@ -103,6 +103,30 @@ public class ScopedSettingsTests extends ESTestCase { assertNull(target.build().getAsInt("archived.foo.bar", null)); } + public void testResetSettingWithIPValidator() { + Settings currentSettings = Settings.builder().put("index.routing.allocation.require._ip", "192.168.0.1,127.0.0.1") + .put("index.some.dyn.setting", 1) + .build(); + Setting dynamicSetting = Setting.intSetting("index.some.dyn.setting", 1, Property.Dynamic, Property.IndexScope); + + IndexScopedSettings settings = new IndexScopedSettings(currentSettings, + new HashSet<>(Arrays.asList(dynamicSetting, IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING))); + Settings s = IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.get(currentSettings); + assertEquals(1, s.size()); + assertEquals("192.168.0.1,127.0.0.1", s.get("_ip")); + Settings.Builder builder = Settings.builder(); + Settings updates = Settings.builder().putNull("index.routing.allocation.require._ip") + .put("index.some.dyn.setting", 1).build(); + settings.validate(updates); + settings.updateDynamicSettings(updates, + Settings.builder().put(currentSettings), builder, "node"); + currentSettings = builder.build(); + s = IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.get(currentSettings); + assertEquals(0, s.size()); + assertEquals(1, dynamicSetting.get(currentSettings).intValue()); + assertEquals(1, currentSettings.size()); + } + public void testAddConsumer() { Setting testSetting = Setting.intSetting("foo.bar", 1, Property.Dynamic, Property.NodeScope); Setting testSetting2 = Setting.intSetting("foo.bar.baz", 1, Property.Dynamic, Property.NodeScope);