Skip to content

Commit

Permalink
Changed mappings from String to convention of BytesReference
Browse files Browse the repository at this point in the history
  • Loading branch information
markharwood committed Jan 29, 2019
1 parent a0326e4 commit aebbc9b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR

private Settings settings = EMPTY_SETTINGS;

private String mappings = null;
private BytesReference mappings = null;

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

Expand Down Expand Up @@ -252,7 +252,8 @@ private PutIndexTemplateRequest internalMapping(Map<String, Object> source) {
builder.map(source);
Objects.requireNonNull(builder.contentType());
try {
mappings = XContentHelper.convertToJson(BytesReference.bytes(builder), false, false, builder.contentType());
mappings = new BytesArray(
XContentHelper.convertToJson(BytesReference.bytes(builder), false, false, builder.contentType()));
return this;
} catch (IOException e) {
throw new UncheckedIOException("failed to convert source to json", e);
Expand All @@ -262,7 +263,7 @@ private PutIndexTemplateRequest internalMapping(Map<String, Object> source) {
}
}

public String mappings() {
public BytesReference mappings() {
return this.mappings;
}

Expand Down Expand Up @@ -436,7 +437,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (mappings != null) {
builder.field("mappings");
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappings)) {
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappings.utf8ToString())) {
builder.copyCurrentStructure(parser);
}
}
Expand Down

0 comments on commit aebbc9b

Please sign in to comment.