* Matthew Toseland <toad at amphibian.dyndns.org> [2008-08-22 14:30:57]:

> On Sunday 17 August 2008 12:37, nextgens at freenetproject.org wrote:
> > Author: nextgens
> > Date: 2008-08-17 11:37:00 +0000 (Sun, 17 Aug 2008)
> > New Revision: 21954
> > 
> > Modified:
> >    trunk/freenet/src/freenet/support/io/ArrayBucket.java
> > Log:
> > ArrayBucket: report when maxLenght is < 0 
> > 
> > (If we want to control the ram usage we need to know exactly how much 
> > memory 
> we can allocate)
> > 
> > Modified: trunk/freenet/src/freenet/support/io/ArrayBucket.java
> > ===================================================================
> > --- trunk/freenet/src/freenet/support/io/ArrayBucket.java   2008-08-17 
> 11:35:49 UTC (rev 21953)
> > +++ trunk/freenet/src/freenet/support/io/ArrayBucket.java   2008-08-17 
> 11:37:00 UTC (rev 21954)
> > @@ -1,5 +1,6 @@
> >  package freenet.support.io;
> >  
> > +import freenet.support.Logger;
> >  import java.io.ByteArrayInputStream;
> >  import java.io.ByteArrayOutputStream;
> >  import java.io.IOException;
> > @@ -23,6 +24,8 @@
> >     private final long maxSize;
> >     private long size;
> >     
> > +   private static boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, 
> ArrayBucket.class);
> > +   
> >     public ArrayBucket(long maxSize) {
> >             this("ArrayBucket", maxSize);
> >     }
> > @@ -33,7 +36,7 @@
> >     }
> >  
> >     public ArrayBucket(byte[] initdata, long maxSize) {
> > -           this("ArrayBucket", -1);
> > +           this("ArrayBucket", maxSize);
> >             data.add(initdata);
> >     }
> >  
> > @@ -41,6 +44,8 @@
> >             data = new ArrayList<byte[]>();
> >             this.name = name;
> >             this.maxSize = maxSize;
> > +           if(logDEBUG && maxSize < 0)
> > +                   Logger.minor(this, "Has been called with maxSize<0 !", 
> > new 
> NullPointerException());
> >     }
> >  
> >     public synchronized OutputStream getOutputStream() throws IOException {
> > @@ -91,7 +96,7 @@
> >             public synchronized void write(byte b[], int off, int len) {
> >                     if(readOnly) throw new IllegalStateException("Read 
> > only");
> >                     long sizeIfWritten = size + len;
> > -                   if(maxSize > -1 && maxSize < sizeIfWritten)
> > +                   if(maxSize > -1 && maxSize < sizeIfWritten) // FIXME: 
> > should be IOE but 
> how to do it?
> >                             throw new IllegalArgumentException("The maxSize 
> > of the bucket 
> is "+maxSize+
> >                                     " and writing "+len+ " bytes to it 
> > would make it oversize!");
> 
> throw new IOException("The maxSize of the bucket ...
> 

We can't because it override a method which doesn't.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080822/06a9aa15/attachment.pgp>

Reply via email to