airlift / aircompressor

A port of Snappy, LZO, LZ4, and Zstandard to Java
Apache License 2.0
549 stars 110 forks source link

Fix ZstdOutputStream corruption on double close #182

Closed mszabo-wikia closed 6 months ago

mszabo-wikia commented 6 months ago

ZstdOutputStream will write out the last chunk every time close() is invoked on it, which can cause errors when the output is later decompressed. Per the java.io.Closeable interface documentation, the close() method should have no effect if invoked on an already-closed stream (which is how e.g. the core DeflaterOutputStream behaves as well), so make it a noop if the stream was already closed.

dain commented 6 months ago

Thanks!