harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Regis <xu.re...@gmail.com>
Subject Re: [classlib] BufferedReader and FileInputStream.available()
Date Thu, 05 Nov 2009 07:07:08 GMT
Mark Hindess wrote:
> In message <4AF0DC18.1000504@gmail.com>, Regis writes:
> Regis, these are really two different issues so lets treat them as
> such.  I actually think fixing the /proc reading is better done in
> the java code.  I've attached a patch that just catches and ignores
> the IOException from the available call.  I think this is reasonable
> since if the exception was "real" then the read will fail if a similar
> exception.  In fact, since the user is doing a read call, having the
> exception thrown by the read is more in keeping with the expectations of
> the user than having an exception thrown by the available call.

Thanks Mark, I ran luni tests with your patch, no regression found, I'll leave 
patch to you to apply :)

invoking in.available before read is a little overhead, in the worst case, one 
read need four system calls, three seek and one read. Actually the condition

if ((in.available() == 0) && (out.position() > offset))

it's only for tty file, for normal file it's not necessary. It's better if we 
can remove the check for normal file, but I have no idea how to do this.

> Making the available call (or part of it) a single native method call
> is a separate issue.
> Regards,
>  Mark.

Best Regards,

View raw message