Skip to content

Commit

Permalink
Fix ILM explain response to allow unknown fields (#38054)
Browse files Browse the repository at this point in the history
IndexLifecycleExplainResponse did not allow unknown fields. This commit
fixes the test and ConstructingObjectParser such that it allows unknown
fields.
  • Loading branch information
hub-cap committed Feb 4, 2019
1 parent fb1e350 commit 24db053
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -99,7 +100,16 @@ protected IndexLifecycleExplainResponse doParseInstance(XContentParser parser) t

@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 {
Expand Down

0 comments on commit 24db053

Please sign in to comment.