mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-02 19:54:27 +02:00
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:
parent
de99182a82
commit
79697cf3d4
@ -365,22 +365,18 @@ public class SnappyOutputStream
|
|||||||
protected void compressInput()
|
protected void compressInput()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (inputCursor <= 0) {
|
|
||||||
return; // no need to dump
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!headerWritten) {
|
if (!headerWritten) {
|
||||||
outputCursor = writeHeader();
|
outputCursor = writeHeader();
|
||||||
headerWritten = true;
|
headerWritten = true;
|
||||||
}
|
}
|
||||||
|
if (inputCursor <= 0) {
|
||||||
|
return; // no need to dump
|
||||||
|
}
|
||||||
// Compress and dump the buffer content
|
// Compress and dump the buffer content
|
||||||
if (!hasSufficientOutputBufferFor(inputCursor)) {
|
if (!hasSufficientOutputBufferFor(inputCursor)) {
|
||||||
dumpOutput();
|
dumpOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
writeBlockPreemble();
|
writeBlockPreemble();
|
||||||
|
|
||||||
int compressedSize = Snappy.compress(inputBuffer, 0, inputCursor, outputBuffer, outputCursor + 4);
|
int compressedSize = Snappy.compress(inputBuffer, 0, inputCursor, outputBuffer, outputCursor + 4);
|
||||||
// Write compressed data size
|
// Write compressed data size
|
||||||
writeInt(outputBuffer, outputCursor, compressedSize);
|
writeInt(outputBuffer, outputCursor, compressedSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user