diff --git a/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseSerializationTests.java b/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseSerializationTests.java index b1947ee971b..950e6db6e7c 100644 --- a/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseSerializationTests.java +++ b/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseSerializationTests.java @@ -49,7 +49,7 @@ public class LicenseSerializationTests extends ESTestCase { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); license.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap(License.REST_VIEW_MODE, "true"))); builder.flush(); - Map map = XContentHelper.convertToMap(builder.bytesStream().bytes(), false).v2(); + Map map = XContentHelper.convertToMap(builder.bytes(), false).v2(); // should have an extra status field, human readable issue_data and expiry_date assertThat(map.get("status"), notNullValue()); @@ -59,14 +59,14 @@ public class LicenseSerializationTests extends ESTestCase { builder = XContentFactory.contentBuilder(XContentType.JSON); license.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.flush(); - map = XContentHelper.convertToMap(builder.bytesStream().bytes(), false).v2(); + map = XContentHelper.convertToMap(builder.bytes(), false).v2(); assertThat(map.get("status"), nullValue()); license = TestUtils.generateLicenses(new TestUtils.LicenseSpec(validLicenseIssueDate, validLicenseExpiryDate)); builder = XContentFactory.contentBuilder(XContentType.JSON); license.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap(License.REST_VIEW_MODE, "true"))); builder.flush(); - map = XContentHelper.convertToMap(builder.bytesStream().bytes(), false).v2(); + map = XContentHelper.convertToMap(builder.bytes(), false).v2(); // should have an extra status field, human readable issue_data and expiry_date assertThat(map.get("status"), notNullValue()); @@ -76,14 +76,14 @@ public class LicenseSerializationTests extends ESTestCase { builder = XContentFactory.contentBuilder(XContentType.JSON); license.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.flush(); - map = XContentHelper.convertToMap(builder.bytesStream().bytes(), false).v2(); + map = XContentHelper.convertToMap(builder.bytes(), false).v2(); assertThat(map.get("status"), nullValue()); license = TestUtils.generateLicenses(new TestUtils.LicenseSpec(invalidLicenseIssueDate, validLicenseExpiryDate)); builder = XContentFactory.contentBuilder(XContentType.JSON); license.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap(License.REST_VIEW_MODE, "true"))); builder.flush(); - map = XContentHelper.convertToMap(builder.bytesStream().bytes(), false).v2(); + map = XContentHelper.convertToMap(builder.bytes(), false).v2(); // should have an extra status field, human readable issue_data and expiry_date assertThat(map.get("status"), notNullValue()); @@ -93,7 +93,7 @@ public class LicenseSerializationTests extends ESTestCase { builder = XContentFactory.contentBuilder(XContentType.JSON); license.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.flush(); - map = XContentHelper.convertToMap(builder.bytesStream().bytes(), false).v2(); + map = XContentHelper.convertToMap(builder.bytes(), false).v2(); assertThat(map.get("status"), nullValue()); } } diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/PutLicenseResponseTests.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/PutLicenseResponseTests.java index 5bec19a549c..1f38970fa2b 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/PutLicenseResponseTests.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/PutLicenseResponseTests.java @@ -42,7 +42,7 @@ public class PutLicenseResponseTests extends ESTestCase { response.toXContent(contentBuilder, ToXContent.EMPTY_PARAMS); contentBuilder.endObject(); - Map map = XContentHelper.convertToMap(contentBuilder.bytesStream().bytes(), false).v2(); + Map map = XContentHelper.convertToMap(contentBuilder.bytes(), false).v2(); assertThat(map.containsKey("acknowledged"), equalTo(true)); boolean actualAcknowledged = (boolean) map.get("acknowledged"); assertThat(actualAcknowledged, equalTo(acknowledged)); diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporter.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporter.java index 9713d1d9aeb..00029426569 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporter.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporter.java @@ -199,18 +199,15 @@ public class HttpExporter extends Exporter { } builder.endObject(); builder.endObject(); - - // Adds action metadata line bulk separator - builder.flush(); // Flush is needed here because the separator is written directly in the builder's stream - builder.stream().write(builder.contentType().xContent().streamSeparator()); - - // Render the MarvelDoc - renderer.render(marvelDoc, xContentType, out); - - // Adds final bulk separator - builder.flush(); - builder.stream().write(builder.contentType().xContent().streamSeparator()); } + // Adds action metadata line bulk separator + out.write(xContentType.xContent().streamSeparator()); + + // Render the MarvelDoc + renderer.render(marvelDoc, xContentType, out); + + // Adds final bulk separator + out.write(xContentType.xContent().streamSeparator()); } @SuppressWarnings("unchecked")