This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [cp-patches] Re: Patch: FYI: fix http Headers oddity


Bryce McKinlay wrote:
> >>>>Does anyone know why we use the custom "LineInputStream" class instead 
> >>>>of, say, BufferedReader here? At one point BufferedReader.readLine() 
> >>>>was buggy and could "read too much" and block before returning a line, 
> >>>>but I believe we have fixed that. Code re-use would help to avoid bugs 
> >>>>like this ;-)
> >>>>
> >>>Erm, because LineInputStream is an InputStream dealing with bytes, and
> >>>BufferedReader is a Reader dealing with chars.
> >>>
> >>Why is this distinction important? We are converting the result to chars 
> >>(well, a String) anyway.
> >>   
> ...
> However, Tromey did point out a good reason on IRC earlier today: 
> BufferedReader.readLine() would read beyond the end of the headers on 
> the underlying stream.

Exactly.

> Since the underlying stream may really be bytes 
> and not characters, we need a mechanism to reset the stream back to the 
> first byte after the headers when it reads past the last EOL.

In fact we don't need any such mechanism, because LineInputStream
already exists and works.
-- 
Chris Burdess


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]