On Monday 14 April 2008 04:54, nextgens at freenetproject.org wrote:
> Author: nextgens
> Date: 2008-04-14 03:54:31 +0000 (Mon, 14 Apr 2008)
> New Revision: 19297
> 
> Modified:
>    trunk/freenet/src/freenet/support/io/BaseFileBucket.java
> Log:
> fix #729 and #963: Temporary files grow until fill disk

Okay, I think I see what's going on here.

Firstly, don't use a double for counting things, use a long.

Secondly, toClose.length is an integer anyway: java doesn't support arrays of 
over 2 billion elements. Thirdly, if it did, you could just loop over a long.

So all in all I don't see any useful change here, but please enlighten me if 
there is one.
> 
> Modified: trunk/freenet/src/freenet/support/io/BaseFileBucket.java
> ===================================================================
> --- trunk/freenet/src/freenet/support/io/BaseFileBucket.java  2008-04-14 
03:28:27 UTC (rev 19296)
> +++ trunk/freenet/src/freenet/support/io/BaseFileBucket.java  2008-04-14 
03:54:31 UTC (rev 19297)
> @@ -393,17 +393,27 @@
>               
>               if(toClose != null) {
>                       Logger.error(this, "Streams open 
free()ing "+this+" : "+StringArray.toString(toClose), new 
Exception("debug"));
> -                     for(int i=0;i<toClose.length;i++) {
> -                             try {
> -                                     if(toClose[i] instanceof 
> FileBucketOutputStream) {
> -                                             ((FileBucketOutputStream) 
> toClose[i]).close();
> -                                     } else {
> -                                             ((FileBucketInputStream) 
> toClose[i]).close();
> +                     double toCloseLength = toClose.length;
> +                     while(toCloseLength > 0) {
> +                             int toCloseThisRound;
> +                             if(toCloseLength <= Integer.MAX_VALUE) {
> +                                     toCloseThisRound = (int) toCloseLength;
> +                                     toCloseLength = 0;
> +                             } else 
> +                                     toCloseLength -= (toCloseThisRound = 
> Integer.MAX_VALUE);
> +
> +                             for(int i=0; i<toCloseThisRound; i++) {
> +                                     try {
> +                                             if(toClose[i] instanceof 
> FileBucketOutputStream) {
> +                                                     
> ((FileBucketOutputStream) toClose[i]).close();
> +                                             } else {
> +                                                     
> ((FileBucketInputStream) toClose[i]).close();
> +                                             }
> +                                     } catch (IOException e) {
> +                                             Logger.error(this, "Caught 
> closing stream in free(): "+e, e);
> +                                     } catch (Throwable t) {
> +                                             Logger.error(this, "Caught 
> closing stream in free(): "+t, t);
>                                       }
> -                             } catch (IOException e) {
> -                                     Logger.error(this, "Caught closing 
> stream in free(): "+e, e);
> -                             } catch (Throwable t) {
> -                                     Logger.error(this, "Caught closing 
> stream in free(): "+t, t);
>                               }
>                       }
>               }
> 
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080415/203d2ce6/attachment.pgp>

Reply via email to