change snappyOutputStream writeHeader order to fix when outputStream… (#229)

* change snappyOutputStream  writeHeader order to fix when outputStream doest't write bytes, it will also generate a snappy header after closed
This commit is contained in:
Neil 2019-03-26 11:59:24 +08:00 committed by Taro L. Saito
parent de99182a82
commit 79697cf3d4
1 changed files with 3 additions and 7 deletions

View File

@ -365,22 +365,18 @@ public class SnappyOutputStream
protected void compressInput()
throws IOException
{
if (inputCursor <= 0) {
return; // no need to dump
}
if (!headerWritten) {
outputCursor = writeHeader();
headerWritten = true;
}
if (inputCursor <= 0) {
return; // no need to dump
}
// Compress and dump the buffer content
if (!hasSufficientOutputBufferFor(inputCursor)) {
dumpOutput();
}
writeBlockPreemble();
int compressedSize = Snappy.compress(inputBuffer, 0, inputCursor, outputBuffer, outputCursor + 4);
// Write compressed data size
writeInt(outputBuffer, outputCursor, compressedSize);