Skip to content

Commit 0d23a0b

Browse files
Speed up toXContent Collection Serialization in some Spots (#78742) (#78755)
Found this when benchmarking large cluster states. When serializing collections we'd mostly not take any advantage of what we know about the collection contents (like we do in `StreamOutput`). This PR adds a couple of helpers to the x-content-builder similar to what we have on `StreamOutput` to allow for faster serializing by avoiding the writer lookup and some self-reference checks.
1 parent 0a35034 commit 0d23a0b

File tree

50 files changed

+151
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+151
-74
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/GeoIpStatsResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public Map<String, DatabaseInfo> getDatabases() {
156156
@Override
157157
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
158158
builder.startObject();
159-
builder.field("files_in_temp", filesInTemp);
159+
builder.stringListField("files_in_temp", filesInTemp);
160160
builder.field("databases", databases.entrySet().stream()
161161
.sorted(Map.Entry.comparingByKey())
162162
.map(Map.Entry::getValue)

client/rest-high-level/src/main/java/org/elasticsearch/client/ccr/PutAutoFollowPatternRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public void setFollowIndexNamePattern(String followIndexNamePattern) {
7474
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
7575
builder.startObject();
7676
builder.field(PutFollowRequest.REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
77-
builder.field(LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns);
77+
builder.stringListField(LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns);
7878
if (leaderIndexExclusionPatterns.isEmpty() == false) {
79-
builder.field(LEADER_EXCLUSION_PATTERNS_FIELD.getPreferredName(), leaderIndexExclusionPatterns);
79+
builder.stringListField(LEADER_EXCLUSION_PATTERNS_FIELD.getPreferredName(), leaderIndexExclusionPatterns);
8080
}
8181
if (followIndexNamePattern != null) {
8282
builder.field(FOLLOW_PATTERN_FIELD.getPreferredName(), followIndexNamePattern);

client/rest-high-level/src/main/java/org/elasticsearch/client/enrich/PutPolicyRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
9696
{
9797
builder.startObject(type);
9898
{
99-
builder.field(NamedPolicy.INDICES_FIELD.getPreferredName(), indices);
99+
builder.stringListField(NamedPolicy.INDICES_FIELD.getPreferredName(), indices);
100100
if (query != null) {
101101
builder.field(NamedPolicy.QUERY_FIELD.getPreferredName(), asMap(query, XContentType.JSON));
102102
}
103103
builder.field(NamedPolicy.MATCH_FIELD_FIELD.getPreferredName(), matchField);
104-
builder.field(NamedPolicy.ENRICH_FIELDS_FIELD.getPreferredName(), enrichFields);
104+
builder.stringListField(NamedPolicy.ENRICH_FIELDS_FIELD.getPreferredName(), enrichFields);
105105
}
106106
builder.endObject();
107107
}

client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
419419
if (template != null) {
420420
builder.field("template", template);
421421
} else {
422-
builder.field("index_patterns", indexPatterns);
422+
builder.stringListField("index_patterns", indexPatterns);
423423
}
424424

425425
builder.field("order", order);

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/EvaluateDataFrameRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public Optional<ValidationException> validate() {
118118
@Override
119119
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
120120
builder.startObject();
121-
builder.array(INDEX.getPreferredName(), indices.toArray());
121+
builder.stringListField(INDEX.getPreferredName(), indices);
122122
if (queryConfig != null) {
123123
builder.field(QUERY.getPreferredName(), queryConfig.getQuery());
124124
}

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetDatafeedRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
139139
builder.startObject();
140140

141141
if (datafeedIds.isEmpty() == false) {
142-
builder.field(DATAFEED_IDS.getPreferredName(), datafeedIds);
142+
builder.stringListField(DATAFEED_IDS.getPreferredName(), datafeedIds);
143143
}
144144

145145
if (allowNoMatch != null) {

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetJobRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
139139
builder.startObject();
140140

141141
if (jobIds.isEmpty() == false) {
142-
builder.field(JOB_IDS.getPreferredName(), jobIds);
142+
builder.stringListField(JOB_IDS.getPreferredName(), jobIds);
143143
}
144144

145145
if (allowNoMatch != null) {

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/UpdateFilterRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
103103
builder.field(MlFilter.DESCRIPTION.getPreferredName(), description);
104104
}
105105
if (addItems != null) {
106-
builder.field(ADD_ITEMS.getPreferredName(), addItems);
106+
builder.stringListField(ADD_ITEMS.getPreferredName(), addItems);
107107
}
108108
if (removeItems != null) {
109-
builder.field(REMOVE_ITEMS.getPreferredName(), removeItems);
109+
builder.stringListField(REMOVE_ITEMS.getPreferredName(), removeItems);
110110
}
111111
builder.endObject();
112112
return builder;

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/calendars/Calendar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public String getDescription() {
7575
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
7676
builder.startObject();
7777
builder.field(ID.getPreferredName(), id);
78-
builder.field(JOB_IDS.getPreferredName(), jobIds);
78+
builder.stringListField(JOB_IDS.getPreferredName(), jobIds);
7979
if (description != null) {
8080
builder.field(DESCRIPTION.getPreferredName(), description);
8181
}

libs/x-content/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import java.util.Arrays;
2525
import java.util.Base64;
2626
import java.util.Calendar;
27+
import java.util.Collection;
2728
import java.util.Collections;
2829
import java.util.Date;
30+
import java.util.EnumSet;
2931
import java.util.GregorianCalendar;
3032
import java.util.HashMap;
3133
import java.util.IdentityHashMap;
@@ -869,6 +871,58 @@ private XContentBuilder value(ToXContent value, ToXContent.Params params) throws
869871
// Maps & Iterable
870872
//////////////////////////////////
871873

874+
public XContentBuilder stringListField(String name, Collection<String> values) throws IOException {
875+
field(name);
876+
if (values == null) {
877+
return nullValue();
878+
}
879+
startArray();
880+
for (String value : values) {
881+
value(value);
882+
}
883+
endArray();
884+
return this;
885+
}
886+
887+
public XContentBuilder xContentList(String name, Collection<? extends ToXContent> values) throws IOException {
888+
field(name);
889+
if (values == null) {
890+
return nullValue();
891+
}
892+
startArray();
893+
for (ToXContent value : values) {
894+
value(value);
895+
}
896+
endArray();
897+
return this;
898+
}
899+
900+
public XContentBuilder xContentList(String name, ToXContent... values) throws IOException {
901+
field(name);
902+
if (values == null) {
903+
return nullValue();
904+
}
905+
startArray();
906+
for (ToXContent value : values) {
907+
value(value);
908+
}
909+
endArray();
910+
return this;
911+
}
912+
913+
public XContentBuilder enumSet(String name, EnumSet<?> values) throws IOException {
914+
field(name);
915+
if (values == null) {
916+
return nullValue();
917+
}
918+
startArray();
919+
for (Enum<?> value : values) {
920+
value(value);
921+
}
922+
endArray();
923+
return this;
924+
}
925+
872926
public XContentBuilder field(String name, Map<String, Object> values) throws IOException {
873927
return field(name).map(values);
874928
}
@@ -877,6 +931,32 @@ public XContentBuilder map(Map<String, ?> values) throws IOException {
877931
return map(values, true, true);
878932
}
879933

934+
public XContentBuilder stringStringMap(String name, Map<String, String> values) throws IOException {
935+
field(name);
936+
if (values == null) {
937+
return nullValue();
938+
}
939+
startObject();
940+
for (Map.Entry<String, String> value : values.entrySet()) {
941+
field(value.getKey());
942+
value(value.getValue());
943+
}
944+
return endObject();
945+
}
946+
947+
public XContentBuilder xContentValuesMap(String name, Map<String, ? extends ToXContent> values) throws IOException {
948+
field(name);
949+
if (values == null) {
950+
return nullValue();
951+
}
952+
startObject();
953+
for (Map.Entry<String, ? extends ToXContent> value : values.entrySet()) {
954+
field(value.getKey());
955+
value(value.getValue());
956+
}
957+
return endObject();
958+
}
959+
880960
/** writes a map without the start object and end object headers */
881961
public XContentBuilder mapContents(Map<String, ?> values) throws IOException {
882962
return map(values, true, false);
@@ -974,6 +1054,11 @@ public XContentBuilder percentageField(String rawFieldName, String readableField
9741054
return this;
9751055
}
9761056

1057+
public XContentBuilder field(String name, Enum<?> value) throws IOException {
1058+
field(name);
1059+
return value(value == null ? null : value.toString());
1060+
}
1061+
9771062
////////////////////////////////////////////////////////////////////////////
9781063
// Raw fields
9791064
//////////////////////////////////

server/src/main/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ public void writeTo(StreamOutput out) throws IOException {
405405
@Override
406406
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
407407
builder.startObject();
408-
builder.field(INDICES_FIELD.getPreferredName(), indices);
409-
builder.field(ALIASES_FIELD.getPreferredName(), aliases);
410-
builder.field(DATA_STREAMS_FIELD.getPreferredName(), dataStreams);
408+
builder.xContentList(INDICES_FIELD.getPreferredName(), indices);
409+
builder.xContentList(ALIASES_FIELD.getPreferredName(), aliases);
410+
builder.xContentList(DATA_STREAMS_FIELD.getPreferredName(), dataStreams);
411411
builder.endObject();
412412
return builder;
413413
}

server/src/main/java/org/elasticsearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
8787
for (Map.Entry<String, List<String>> entry : overlappingTemplates.entrySet()) {
8888
builder.startObject();
8989
builder.field(NAME.getPreferredName(), entry.getKey());
90-
builder.field(INDEX_PATTERNS.getPreferredName(), entry.getValue());
90+
builder.stringListField(INDEX_PATTERNS.getPreferredName(), entry.getValue());
9191
builder.endObject();
9292
}
9393
builder.endArray();

server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
134134
builder.field(SEARCHABLE_FIELD.getPreferredName(), isSearchable);
135135
builder.field(AGGREGATABLE_FIELD.getPreferredName(), isAggregatable);
136136
if (indices != null) {
137-
builder.field(INDICES_FIELD.getPreferredName(), indices);
137+
builder.array(INDICES_FIELD.getPreferredName(), indices);
138138
}
139139
if (nonSearchableIndices != null) {
140-
builder.field(NON_SEARCHABLE_INDICES_FIELD.getPreferredName(), nonSearchableIndices);
140+
builder.array(NON_SEARCHABLE_INDICES_FIELD.getPreferredName(), nonSearchableIndices);
141141
}
142142
if (nonAggregatableIndices != null) {
143-
builder.field(NON_AGGREGATABLE_INDICES_FIELD.getPreferredName(), nonAggregatableIndices);
143+
builder.array(NON_AGGREGATABLE_INDICES_FIELD.getPreferredName(), nonAggregatableIndices);
144144
}
145145
if (meta.isEmpty() == false) {
146146
builder.startObject("meta");
@@ -149,7 +149,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
149149
for (Map.Entry<String, Set<String>> entry : entries) {
150150
List<String> values = new ArrayList<>(entry.getValue());
151151
values.sort(String::compareTo); // provide predictable order
152-
builder.field(entry.getKey(), values);
152+
builder.stringListField(entry.getKey(), values);
153153
}
154154
builder.endObject();
155155
}

server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesFailure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public FieldCapabilitiesFailure(StreamInput in) throws IOException {
4646
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
4747
builder.startObject();
4848
{
49-
builder.field(INDICES_FIELD.getPreferredName(), indices);
49+
builder.stringListField(INDICES_FIELD.getPreferredName(), indices);
5050
builder.startObject(FAILURE_FIELD.getPreferredName());
5151
{
5252
ElasticsearchException.generateFailureXContent(builder, params, exception, true);

server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
164164
throw new IllegalStateException("cannot serialize non-merged response");
165165
}
166166
builder.startObject();
167-
builder.field(INDICES_FIELD.getPreferredName(), indices);
167+
builder.array(INDICES_FIELD.getPreferredName(), indices);
168168
builder.field(FIELDS_FIELD.getPreferredName(), responseMap);
169169
if (this.failures.size() > 0) {
170170
builder.field(FAILED_INDICES_FIELD.getPreferredName(), getFailedIndices().length);
171-
builder.field(FAILURES_FIELD.getPreferredName(), failures);
171+
builder.xContentList(FAILURES_FIELD.getPreferredName(), failures);
172172
}
173173
builder.endObject();
174174
return builder;

server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
211211
builder.field(TYPE.getPreferredName(), type);
212212
builder.field(ID.getPreferredName(), id);
213213
builder.field(ROUTING.getPreferredName(), routing);
214-
builder.field(STORED_FIELDS.getPreferredName(), storedFields);
214+
builder.array(STORED_FIELDS.getPreferredName(), storedFields);
215215
builder.field(VERSION.getPreferredName(), version);
216216
builder.field(VERSION_TYPE.getPreferredName(), VersionType.toString(versionType));
217217
builder.field(SOURCE.getPreferredName(), fetchSourceContext);

server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
115115
.field(TERM_PARSE_FIELD.getPreferredName(), term)
116116
.field(LAST_COMMITTED_CONFIGURATION_FIELD.getPreferredName(), lastCommittedConfiguration)
117117
.field(LAST_ACCEPTED_CONFIGURATION_FIELD.getPreferredName(), lastAcceptedConfiguration)
118-
.field(VOTING_CONFIG_EXCLUSIONS_FIELD.getPreferredName(), votingConfigExclusions);
118+
.xContentList(VOTING_CONFIG_EXCLUSIONS_FIELD.getPreferredName(), votingConfigExclusions);
119119
}
120120

121121
public static CoordinationMetadata fromXContent(XContentParser parser) throws IOException {

server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ public void writeTo(StreamOutput out) throws IOException {
216216
@Override
217217
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
218218
builder.startObject();
219-
builder.field(INDEX_PATTERNS.getPreferredName(), this.indexPatterns);
219+
builder.stringListField(INDEX_PATTERNS.getPreferredName(), this.indexPatterns);
220220
if (this.template != null) {
221221
builder.field(TEMPLATE.getPreferredName(), this.template);
222222
}
223223
if (this.componentTemplates != null) {
224-
builder.field(COMPOSED_OF.getPreferredName(), this.componentTemplates);
224+
builder.stringListField(COMPOSED_OF.getPreferredName(), this.componentTemplates);
225225
}
226226
if (this.priority != null) {
227227
builder.field(PRIORITY.getPreferredName(), priority);

server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
429429
builder.startObject();
430430
builder.field(NAME_FIELD.getPreferredName(), name);
431431
builder.field(TIMESTAMP_FIELD_FIELD.getPreferredName(), timeStampField);
432-
builder.field(INDICES_FIELD.getPreferredName(), indices);
432+
builder.xContentList(INDICES_FIELD.getPreferredName(), indices);
433433
builder.field(GENERATION_FIELD.getPreferredName(), generation);
434434
if (metadata != null) {
435435
builder.field(METADATA_FIELD.getPreferredName(), metadata);

server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamAlias.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public static DataStreamAlias fromXContent(XContentParser parser) throws IOExcep
279279
@Override
280280
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
281281
builder.startObject(name);
282-
builder.field(DATA_STREAMS_FIELD.getPreferredName(), dataStreams);
282+
builder.stringListField(DATA_STREAMS_FIELD.getPreferredName(), dataStreams);
283283
if (writeDataStream != null) {
284284
builder.field(WRITE_DATA_STREAM_FIELD.getPreferredName(), writeDataStream);
285285
}

server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamMetadata.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@ public static DataStreamMetadata fromXContent(XContentParser parser) throws IOEx
127127

128128
@Override
129129
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
130-
builder.startObject(DATA_STREAM.getPreferredName());
131-
for (Map.Entry<String, DataStream> dataStream : dataStreams.entrySet()) {
132-
builder.field(dataStream.getKey(), dataStream.getValue());
133-
}
134-
builder.endObject();
130+
builder.xContentValuesMap(DATA_STREAM.getPreferredName(), dataStreams);
135131
builder.startObject(DATA_STREAM_ALIASES.getPreferredName());
136132
for (Map.Entry<String, DataStreamAlias> dataStream : dataStreamAliases.entrySet()) {
137133
dataStream.getValue().toXContent(builder, params);

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,7 @@ public static void toXContent(IndexMetadata indexMetadata, XContentBuilder build
14761476
}
14771477

14781478
for (ObjectObjectCursor<String, DiffableStringMap> cursor : indexMetadata.customData) {
1479-
builder.field(cursor.key);
1480-
builder.map(cursor.value);
1479+
builder.stringStringMap(cursor.key, cursor.value);
14811480
}
14821481

14831482
if (context != Metadata.XContentContext.API) {

server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private static void toInnerXContent(IndexTemplateMetadata indexTemplateMetadata,
390390
if (indexTemplateMetadata.version() != null) {
391391
builder.field("version", indexTemplateMetadata.version());
392392
}
393-
builder.field("index_patterns", indexTemplateMetadata.patterns());
393+
builder.stringListField("index_patterns", indexTemplateMetadata.patterns());
394394

395395
builder.startObject("settings");
396396
indexTemplateMetadata.settings().toXContent(builder, params);

server/src/main/java/org/elasticsearch/cluster/metadata/ItemUsage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public Set<String> getComposableTemplates() {
7777
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
7878
builder.startObject();
7979
if (this.indices != null) {
80-
builder.field("indices", this.indices);
80+
builder.stringListField("indices", this.indices);
8181
}
8282
if (this.dataStreams != null) {
83-
builder.field("data_streams", this.dataStreams);
83+
builder.stringListField("data_streams", this.dataStreams);
8484
}
8585
if (this.composableTemplates != null) {
86-
builder.field("composable_templates", this.composableTemplates);
86+
builder.stringListField("composable_templates", this.composableTemplates);
8787
}
8888
builder.endObject();
8989
return builder;

server/src/main/java/org/elasticsearch/cluster/metadata/Manifest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
135135
builder.field(CURRENT_TERM_PARSE_FIELD.getPreferredName(), currentTerm);
136136
builder.field(CLUSTER_STATE_VERSION_PARSE_FIELD.getPreferredName(), clusterStateVersion);
137137
builder.field(GENERATION_PARSE_FIELD.getPreferredName(), globalGeneration);
138-
builder.array(INDEX_GENERATIONS_PARSE_FIELD.getPreferredName(), indexEntryList().toArray());
138+
builder.xContentList(INDEX_GENERATIONS_PARSE_FIELD.getPreferredName(), indexEntryList());
139139
return builder;
140140
}
141141

server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
525525
builder.field("failed_attempts", failedAllocations);
526526
}
527527
if (failedNodeIds.isEmpty() == false) {
528-
builder.field("failed_nodes", failedNodeIds);
528+
builder.stringListField("failed_nodes", failedNodeIds);
529529
}
530530
builder.field("delayed", delayed);
531531
String details = getDetails();

0 commit comments

Comments
 (0)