Skip to content

Commit 5e17f00

Browse files
committed
Tweak toXContent implementation of ParametrizedFieldMapper (#59968)
ParametrizedFieldMapper overrides `toXContent` from `FieldMapper`, yet it could override `doXContentBody` and rely on the `toXContent` from the base class. Additionally, this allows to make `doXContentBody` final. Also, toXContent is still overridden only to make it final.
1 parent 19fe3e5 commit 5e17f00

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

server/src/main/java/org/elasticsearch/index/mapper/ParametrizedFieldMapper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ protected final void mergeOptions(FieldMapper other, List<String> conflicts) {
109109

110110
@Override
111111
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
112-
builder.startObject(simpleName());
112+
return super.toXContent(builder, params);
113+
}
114+
115+
@Override
116+
protected final void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
113117
builder.field("type", contentType());
114-
boolean includeDefaults = params.paramAsBoolean("include_defaults", false);
115118
getMergeBuilder().toXContent(builder, includeDefaults);
116119
multiFields.toXContent(builder, params);
117120
copyTo.toXContent(builder, params);
118-
return builder.endObject();
119121
}
120122

121123
/**

0 commit comments

Comments
 (0)