Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure empty streams get deflated properly #865

Merged
merged 1 commit into from
May 13, 2017

Conversation

mrdziuban
Copy link
Contributor

The current behavior of fs2.compress.deflate is to skip deflation on empty streams. I would argue that this behavior is incorrect given the following example:

import java.io.ByteArrayOutputStream
import java.util.zip.{Deflater, DeflaterOutputStream}

val byteArrayStream = new ByteArrayOutputStream()
val deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true)
val deflaterStream = new DeflaterOutputStream(byteArrayStream, deflater)
deflaterStream.write(Array[Byte]())
deflaterStream.close()
byteArrayStream.toByteArray()
// => Array(3, 0)

These changes fix the behavior by making sure that _deflate_finish is called regardless of whether the stream was empty or not.

@mpilquist
Copy link
Member

👍

@mpilquist mpilquist merged commit 5e38ed8 into typelevel:series/1.0 May 13, 2017
@mrdziuban mrdziuban deleted the empty-data-deflate branch May 13, 2017 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants