Marvel: reset buffer in HttpExporter

The BytesStreamOutput buffer is not reset when exporting multiple documents. It causes the same marvel doc to be indexed many times and it creates very large bulk requests. Bug introduced in elastic/x-pack@8575fd91c4

Original commit: elastic/x-pack-elasticsearch@adac96677d
This commit is contained in:
Tanguy Leroux 2015-11-13 12:40:43 +01:00
parent 0b50bbb5e5
commit a901aeef86
1 changed files with 7 additions and 4 deletions

View File

@ -670,10 +670,13 @@ public class HttpExporter extends Exporter {
// because the renderer might close the outputstream (ex: XContentBuilder) // because the renderer might close the outputstream (ex: XContentBuilder)
try (BytesStreamOutput buffer = new BytesStreamOutput()) { try (BytesStreamOutput buffer = new BytesStreamOutput()) {
for (MarvelDoc marvelDoc : docs) { for (MarvelDoc marvelDoc : docs) {
render(marvelDoc, buffer); try {
render(marvelDoc, buffer);
// write the result to the connection // write the result to the connection
out.write(buffer.bytes().toBytes()); out.write(buffer.bytes().toBytes());
} finally {
buffer.reset();
}
} }
} }
} }