Fix ILM explain response to allow unknown fields (#38054)

IndexLifecycleExplainResponse did not allow unknown fields. This commit
fixes the test and ConstructingObjectParser such that it allows unknown
fields.
This commit is contained in:
Michael Basnight 2019-02-04 14:05:00 -06:00 committed by GitHub
parent fb1e350c81
commit 24db053465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -54,7 +54,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject {
private static final ParseField PHASE_EXECUTION_INFO = new ParseField("phase_execution");
public static final ConstructingObjectParser<IndexLifecycleExplainResponse, Void> PARSER = new ConstructingObjectParser<>(
"index_lifecycle_explain_response",
"index_lifecycle_explain_response", true,
a -> new IndexLifecycleExplainResponse(
(String) a[0],
(boolean) a[1],

View File

@ -33,6 +33,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static org.hamcrest.Matchers.containsString;
@ -99,7 +100,16 @@ public class IndexLifecycleExplainResponseTests extends AbstractXContentTestCase
@Override
protected boolean supportsUnknownFields() {
return false;
return true;
}
@Override
protected Predicate<String> getRandomFieldsExcludeFilter() {
return (field) ->
// actions are plucked from the named registry, and it fails if the action is not in the named registry
field.endsWith("phase_definition.actions")
// This is a bytes reference, so any new fields are tested for equality in this bytes reference.
|| field.contains("step_info");
}
private static class RandomStepInfo implements ToXContentObject {