On Friday 22 August 2008 14:49, Florent Daigni?re wrote:
> * Matthew Toseland <toad at amphibian.dyndns.org> [2008-08-22 14:28:11]:
> 
> > On Sunday 17 August 2008 19:31, nextgens at freenetproject.org wrote:
> > > Author: nextgens
> > > Date: 2008-08-17 18:31:15 +0000 (Sun, 17 Aug 2008)
> > > New Revision: 21977
> > > 
> > > Modified:
> > >    trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
> > > Log:
> > > bug #2501: maybe fix the issue for real
> > > 
> > > Modified: 
trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
> > > ===================================================================
> > > --- trunk/freenet/src/freenet/support/io/LineReadingInputStream.java      
> > 2008-08-17 18:24:10 UTC (rev 21976)
> > > +++ trunk/freenet/src/freenet/support/io/LineReadingInputStream.java      
> > 2008-08-17 18:31:15 UTC (rev 21977)
> > > @@ -33,11 +33,10 @@
> > >           
> > >           byte[] buf = new byte[Math.max(Math.min(128, maxLength), 
Math.min(1024, 
> > bufferSize))];
> > >           int ctr = 0;
> > > -         mark((maxLength+1)*2); // Might be more than maxLengh if we use 
> > > utf8
> > > +         mark(Integer.MAX_VALUE); // Might be more than maxLengh if we 
> > > use 
utf8
> > 
> > How can it EVER be more than maxLength + 2 ? (\r\n) All these parameters 
are 
> > in bytes afaics.
> 
> Some utf8 chars up to 4 bytes.

So? What relevance does that have here? IIRC some UTF8 chars are in fact 6 
bytes. But the parameters are in bytes, aren't they? We can't limit in chars 
because we don't know what the length is until we construct a string.
> 
> > Some impl's are surely going to throw if you do mark(Integer.MAX_VALUE).
> > 
> 
> Which implementations are you talking about? why wouldn't
> Integer.MAX_VALUE be valid?

Because it could require them to cache 2GB of data?
> 
> > Do we ever reset the mark? How do you reset the mark? AFAICS if you don't 
it 
> > will cause it to keep on buffering forever and then OOM, no?
> 
> We don't need to reset the mark; we throw if it's > maxlength

Is there any case in which the mark doesn't get cleared, yet the stream hasn't 
been closed/errored/EOFed?
-------------- 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/20080822/4f86cdb7/attachment.pgp>

Reply via email to