This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: java/3426: java.io.InputStreamReader, infinite loop
- To: nobody at gcc dot gnu dot org
- Subject: Re: java/3426: java.io.InputStreamReader, infinite loop
- From: Tom Tromey <tromey at redhat dot com>
- Date: 29 Jun 2001 22:46:01 -0000
- Cc: gcc-prs at gcc dot gnu dot org,
- Reply-To: Tom Tromey <tromey at redhat dot com>
The following reply was made to PR libgcj/3426; it has been noted by GNATS.
From: Tom Tromey <tromey@redhat.com>
To: david-b@pacbell.net
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/3426: java.io.InputStreamReader, infinite loop
Date: 29 Jun 2001 16:57:54 -0600
>>>>> "David" == david-b <david-b@pacbell.net> writes:
David> The for(;;) loop in the second half of
David> java.io.InputStreamReader will loop infinitely in the following
David> case:
I looked at this and I agree. The problem is that the
InputStreamReader has no way to force the BufferedInputStream to
refill its buffer. So in your scenario, instead of making progress
we simply keep trying the same thing over and over.
One fix might be to make BufferedInputStream.refill package-private
and then call it from InputStreamReader.read while the mark is set.
This is pretty ugly. It is hard to see what else we could do
without rewriting InputStreamReader. I'd prefer not to do that,
I think.
David> "FIXME: what if R == -1 ?" comment which seems like it
David> is what's being hit here.
We definitely have to do something smarter if we hit an encoding
error. Maybe throwing CharConversionException is appropriate?
We currently don't throw that anywhere, which seems odd.
I think we ought to throw it if we detect garbage in the input
stream. What do you think?
Tom