Skip to content

Commit

Permalink
only flush if there is something to flush
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Oct 29, 2010
1 parent 11c5518 commit 8f7a8da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .idea/runConfigurations/ElasticSearch_Tests__compress_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public void close() throws IOException {
* Compress and write the current block to the OutputStream
*/
private void writeCompressedBlock() throws IOException {
encoder.encodeChunk(outputStream, outputBuffer, 0, position);
position = 0;
if (position > 0) {
encoder.encodeChunk(outputStream, outputBuffer, 0, position);
position = 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public StreamOutput wrappedOut() {
* Compress and write the current block to the OutputStream
*/
private void writeCompressedBlock() throws IOException {
encoder.encodeChunk(out, outputBuffer, 0, position);
position = 0;
if (position > 0) {
encoder.encodeChunk(out, outputBuffer, 0, position);
position = 0;
}
}
}

0 comments on commit 8f7a8da

Please sign in to comment.