While setting up a short demo project using the new Java TZlibTransport in 0.9.3, I wrote code like this:
However, when I went to look at the file, I found it mostly empty (with only the header bytes). I had a look at the TZlibTransport code, which seems to be a subclass of TIOStreamTransport that wraps its underlying transport using Java inflater/deflater streams:
However, on its close method it only closes the transport and not the underlying streams, forcing users to flush the transport before closing if they really want to write everything:
I think it would be better if we simply relied on the close() method of the TIOStreamTransport, which closes the input and output streams if they have been created. Additionally, it would be better to create the input stream on the first read and the output stream on the first write: otherwise, we will get an error during closing if we're only reading (as TIOStreamTransport will still try to close the output side, resulting in writes from the deflater).
I have a first version of a fix for these issues: I'll turn it into a pull request on Github.