Skip to content

Commit 6c241f3

Browse files
committed
protected against a wrong format in the index.auto_expand_replicas setting
1 parent d2e61af commit 6c241f3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
5555
try {
5656
final int numberOfReplicas = event.state().nodes().dataNodes().size() - 1;
5757

58-
int min = Integer.parseInt(autoExpandReplicas.substring(0, autoExpandReplicas.indexOf('-')));
58+
int min;
5959
int max;
60-
String sMax = autoExpandReplicas.substring(autoExpandReplicas.indexOf('-') + 1);
61-
if (sMax.equals("all")) {
62-
max = event.state().nodes().dataNodes().size() - 1;
63-
} else {
64-
max = Integer.parseInt(sMax);
60+
try {
61+
min = Integer.parseInt(autoExpandReplicas.substring(0, autoExpandReplicas.indexOf('-')));
62+
String sMax = autoExpandReplicas.substring(autoExpandReplicas.indexOf('-') + 1);
63+
if (sMax.equals("all")) {
64+
max = event.state().nodes().dataNodes().size() - 1;
65+
} else {
66+
max = Integer.parseInt(sMax);
67+
}
68+
} catch (Exception e) {
69+
logger.warn("failed to set [{}], wrong format [{}]", IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, autoExpandReplicas);
70+
continue;
6571
}
6672

6773
// same value, nothing to do there

0 commit comments

Comments
 (0)