@@ -282,6 +282,18 @@ public final void validate(final Settings settings, final boolean validateDepend
282
282
validate (settings , validateDependencies , false , false );
283
283
}
284
284
285
+ /**
286
+ * Validates that all settings are registered and valid.
287
+ *
288
+ * @param settings the settings to validate
289
+ * @param validateDependencies true if dependent settings should be validated
290
+ * @param validateInternalIndex true if internal index settings should be validated
291
+ * @see Setting#getSettingsDependencies(String)
292
+ */
293
+ public final void validate (final Settings settings , final boolean validateDependencies , final boolean validateInternalIndex ) {
294
+ validate (settings , validateDependencies , false , false , validateInternalIndex );
295
+ }
296
+
285
297
/**
286
298
* Validates that all settings are registered and valid.
287
299
*
@@ -296,6 +308,25 @@ public final void validate(
296
308
final boolean validateDependencies ,
297
309
final boolean ignorePrivateSettings ,
298
310
final boolean ignoreArchivedSettings ) {
311
+ validate (settings , validateDependencies , ignorePrivateSettings , ignoreArchivedSettings , false );
312
+ }
313
+
314
+ /**
315
+ * Validates that all settings are registered and valid.
316
+ *
317
+ * @param settings the settings
318
+ * @param validateDependencies true if dependent settings should be validated
319
+ * @param ignorePrivateSettings true if private settings should be ignored during validation
320
+ * @param ignoreArchivedSettings true if archived settings should be ignored during validation
321
+ * @param validateInternalIndex true if index internal settings should be validated
322
+ * @see Setting#getSettingsDependencies(String)
323
+ */
324
+ public final void validate (
325
+ final Settings settings ,
326
+ final boolean validateDependencies ,
327
+ final boolean ignorePrivateSettings ,
328
+ final boolean ignoreArchivedSettings ,
329
+ final boolean validateInternalIndex ) {
299
330
final List <RuntimeException > exceptions = new ArrayList <>();
300
331
for (final String key : settings .keySet ()) { // settings iterate in deterministic fashion
301
332
if (isPrivateSetting (key ) && ignorePrivateSettings ) {
@@ -305,7 +336,7 @@ public final void validate(
305
336
continue ;
306
337
}
307
338
try {
308
- validate (key , settings , validateDependencies );
339
+ validate (key , settings , validateDependencies , validateInternalIndex );
309
340
} catch (final RuntimeException ex ) {
310
341
exceptions .add (ex );
311
342
}
@@ -314,9 +345,27 @@ public final void validate(
314
345
}
315
346
316
347
/**
317
- * Validates that the setting is valid
348
+ * Validates that the settings is valid.
349
+ *
350
+ * @param key the key of the setting to validate
351
+ * @param settings the settings
352
+ * @param validateDependencies true if dependent settings should be validated
353
+ * @throws IllegalArgumentException if the setting is invalid
318
354
*/
319
- void validate (String key , Settings settings , boolean validateDependencies ) {
355
+ void validate (final String key , final Settings settings , final boolean validateDependencies ) {
356
+ validate (key , settings , validateDependencies , false );
357
+ }
358
+
359
+ /**
360
+ * Validates that the settings is valid.
361
+ *
362
+ * @param key the key of the setting to validate
363
+ * @param settings the settings
364
+ * @param validateDependencies true if dependent settings should be validated
365
+ * @param validateInternalIndex true if internal index settings should be validated
366
+ * @throws IllegalArgumentException if the setting is invalid
367
+ */
368
+ void validate (final String key , final Settings settings , final boolean validateDependencies , final boolean validateInternalIndex ) {
320
369
Setting setting = getRaw (key );
321
370
if (setting == null ) {
322
371
LevensteinDistance ld = new LevensteinDistance ();
@@ -356,6 +405,11 @@ void validate(String key, Settings settings, boolean validateDependencies) {
356
405
}
357
406
}
358
407
}
408
+ // the only time that validateInternalIndex should be true is if this call is coming via the update settings API
409
+ if (validateInternalIndex && setting .getProperties ().contains (Setting .Property .InternalIndex )) {
410
+ throw new IllegalArgumentException (
411
+ "can not update internal setting [" + setting .getKey () + "]; this setting is managed via a dedicated API" );
412
+ }
359
413
}
360
414
setting .get (settings );
361
415
}
0 commit comments