On Fri, Jul 18, 2008 at 7:17 AM, <toad at freenetproject.org> wrote:
> Author: toad
> Date: 2008-07-17 23:17:54 +0000 (Thu, 17 Jul 2008)
> New Revision: 21205
>
> Modified:
> branches/db4o/freenet/src/freenet/support/compress/GzipCompressor.java
> Log:
> Fix Streams open free()ing ...
>
> Modified:
> branches/db4o/freenet/src/freenet/support/compress/GzipCompressor.java
> ===================================================================
> --- branches/db4o/freenet/src/freenet/support/compress/GzipCompressor.java
> 2008-07-17 22:55:53 UTC (rev 21204)
> +++ branches/db4o/freenet/src/freenet/support/compress/GzipCompressor.java
> 2008-07-17 23:17:54 UTC (rev 21205)
> @@ -12,6 +12,7 @@
> import freenet.support.Logger;
> import freenet.support.api.Bucket;
> import freenet.support.api.BucketFactory;
> +import freenet.support.io.Closer;
>
> public class GzipCompressor extends Compressor {
>
> @@ -54,12 +55,19 @@
> output = preferred;
> else
> output = bf.makeBucket(-1);
> - InputStream is = data.getInputStream();
> - OutputStream os = output.getOutputStream();
> + InputStream is = null;
> + OutputStream os = null;
> + try {
> + is = data.getInputStream();
> + os = output.getOutputStream();
> decompress(is, os, maxLength, maxCheckSizeLength);
> - os.close();
> - is.close();
> + os.close(); os = null;
> + is.close(); is = null;
> return output;
> + } finally {
> + if(is != null) Closer.close(is);
> + if(os != null) Closer.close(os);
Closer always check for null
> + }
> }
>
> private long decompress(InputStream is, OutputStream os, long
> maxLength, long maxCheckSizeBytes) throws IOException,
> CompressionOutputSizeException {
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>