Skip to content

Commit 79697cf

Browse files
Neilxznxerial
authored andcommitted
change snappyOutputStream writeHeader order to fix when outputStream… (xerial#229)
* change snappyOutputStream writeHeader order to fix when outputStream doest't write bytes, it will also generate a snappy header after closed
1 parent de99182 commit 79697cf

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/main/java/org/xerial/snappy/SnappyOutputStream.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,22 +365,18 @@ protected void dumpOutput()
365365
protected void compressInput()
366366
throws IOException
367367
{
368-
if (inputCursor <= 0) {
369-
return; // no need to dump
370-
}
371-
372368
if (!headerWritten) {
373369
outputCursor = writeHeader();
374370
headerWritten = true;
375371
}
376-
372+
if (inputCursor <= 0) {
373+
return; // no need to dump
374+
}
377375
// Compress and dump the buffer content
378376
if (!hasSufficientOutputBufferFor(inputCursor)) {
379377
dumpOutput();
380378
}
381-
382379
writeBlockPreemble();
383-
384380
int compressedSize = Snappy.compress(inputBuffer, 0, inputCursor, outputBuffer, outputCursor + 4);
385381
// Write compressed data size
386382
writeInt(outputBuffer, outputCursor, compressedSize);

0 commit comments

Comments
 (0)