Skip to content

Commit

Permalink
Fix missing order field in TemplatesMetadata deserialization
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <soosinha@amazon.com>
  • Loading branch information
soosinha committed Aug 30, 2024
1 parent e146f13 commit 0915cb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ public static TemplatesMetadata fromXContent(XContentParser parser) throws IOExc
String currentFieldName = parser.currentName();
if (currentFieldName == null) {
token = parser.nextToken();
if (token == XContentParser.Token.START_OBJECT) {
// move to the field name
token = parser.nextToken();
}
currentFieldName = parser.currentName();
}
if (currentFieldName != null) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.START_OBJECT) {
// move to the field name
token = parser.nextToken();
}
currentFieldName = parser.currentName();
if (currentFieldName != null && parser.currentName() != null) {
do {
builder.put(IndexTemplateMetadata.Builder.fromXContent(parser, parser.currentName()));
}
} while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT);
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,22 @@ public static TemplatesMetadata getTemplatesMetadata() {
return TemplatesMetadata.builder()
.put(
IndexTemplateMetadata.builder("template" + randomAlphaOfLength(3))
.order(1234)
.patterns(Arrays.asList("bar-*", "foo-*"))
.settings(
Settings.builder().put("index.random_index_setting_" + randomAlphaOfLength(3), randomAlphaOfLength(5)).build()
)
.build()
)
.put(
IndexTemplateMetadata.builder("template" + randomAlphaOfLength(3))
.order(5678)
.patterns(Arrays.asList("test-*"))
.settings(
Settings.builder().put("index.random_index_setting_" + randomAlphaOfLength(3), randomAlphaOfLength(5)).build()
)
.build()
)
.build();
}
}

0 comments on commit 0915cb4

Please sign in to comment.