From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Tromey To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: java/3426: java.io.InputStreamReader, infinite loop Date: Fri, 29 Jun 2001 16:26:00 -0000 Message-id: <20010629232601.21361.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg01191.html List-Id: The following reply was made to PR libgcj/3426; it has been noted by GNATS. From: Tom Tromey 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 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