[Pharo-project] ZipWriteStream error when closing it twice. Normal?

Mariano Martinez Peck marianopeck at gmail.com
Tue Jan 24 10:30:11 CET 2012


Hi guys. I found that GZipWriteStream throws an error when closing it
twice. Example:

| aStream zipStream |
aStream := ByteArray new writeStream binary.
zipStream := GZipWriteStream on: aStream.
zipStream close.
zipStream close.

All the streams I know do not throw an error in that case. And moreoever,
it gets things complicated when using #on:do:. For example:

    FileStream
        forceNewFileNamed: testFileName
        do: [ :stream |
            GZipWriteStream
                on: stream binary
                do: [ :gzipStream |
                    FLSerializer newDefault serialize: anObject on:
gzipStream ] ].

In thise case, FLSerializer closes the stream at the end. No matter whether
Fuel should do that or not, the thing is that in this I have the mentioned
problem.

So...my question is, is this a bug?  if it is, do you have a better idea
that changing #close to this:

ZipWriteStream >> close
    literals isNil ifTrue: [
        "#initialize sets this instVar to a specific value. #release puts
it in nil, and #release is called from #flushBlock: which is called from
#close:. Therefore, if it is nil, it means the stream has already been
closed. If we try to close it twice, #flushBlock will throw an error
because its instance variables are with nil"
        ^ self]
    self deflateBlock.
    self flushBlock: true.
    encoder close.


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20120124/999cc11f/attachment.htm>


More information about the Pharo-project mailing list