Skip to content

Commit aebbc9b

Browse files
committed
Changed mappings from String to convention of BytesReference
1 parent a0326e4 commit aebbc9b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
7070

7171
private Settings settings = EMPTY_SETTINGS;
7272

73-
private String mappings = null;
73+
private BytesReference mappings = null;
7474

7575
private final Set<Alias> aliases = new HashSet<>();
7676

@@ -252,7 +252,8 @@ private PutIndexTemplateRequest internalMapping(Map<String, Object> source) {
252252
builder.map(source);
253253
Objects.requireNonNull(builder.contentType());
254254
try {
255-
mappings = XContentHelper.convertToJson(BytesReference.bytes(builder), false, false, builder.contentType());
255+
mappings = new BytesArray(
256+
XContentHelper.convertToJson(BytesReference.bytes(builder), false, false, builder.contentType()));
256257
return this;
257258
} catch (IOException e) {
258259
throw new UncheckedIOException("failed to convert source to json", e);
@@ -262,7 +263,7 @@ private PutIndexTemplateRequest internalMapping(Map<String, Object> source) {
262263
}
263264
}
264265

265-
public String mappings() {
266+
public BytesReference mappings() {
266267
return this.mappings;
267268
}
268269

@@ -436,7 +437,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
436437
if (mappings != null) {
437438
builder.field("mappings");
438439
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
439-
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappings)) {
440+
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappings.utf8ToString())) {
440441
builder.copyCurrentStructure(parser);
441442
}
442443
}

0 commit comments

Comments
 (0)