Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB14C6BEA for ; Sun, 10 Jul 2011 05:29:34 +0000 (UTC) Received: (qmail 73763 invoked by uid 500); 10 Jul 2011 05:29:33 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 73406 invoked by uid 500); 10 Jul 2011 05:29:27 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 73393 invoked by uid 99); 10 Jul 2011 05:29:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jul 2011 05:29:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jul 2011 05:29:21 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id CA586421EF for ; Sun, 10 Jul 2011 05:28:59 +0000 (UTC) Date: Sun, 10 Jul 2011 05:28:59 +0000 (UTC) From: "Mike Thomas (JIRA)" To: issues@commons.apache.org Message-ID: <1570956835.728.1310275739825.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1578445998.726.1310275619777.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (IO-277) ReaderInputStream enters infinite loop when it encounters an unmappable character MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/IO-277?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mike Thomas updated IO-277: --------------------------- Attachment: TestReaderInputStreamLoop.java > ReaderInputStream enters infinite loop when it encounters an unmappable character > --------------------------------------------------------------------------------- > > Key: IO-277 > URL: https://issues.apache.org/jira/browse/IO-277 > Project: Commons IO > Issue Type: Bug > Components: Streams/Writers > Affects Versions: 2.0.1 > Reporter: Mike Thomas > Attachments: TestReaderInputStreamLoop.java > > > The ReaderInputStream.read(byte[] b, int off, int len) method enters an infinite loop when its CharsetEncoder encounters an unmappable character in the input buffer. > When its CharsetEncoder encounters an unmappable character, the value of CoderResult lastCoderResult.isUnmappable() == true, and Reader.read() is not invoked on the underlying Reader ever again. > Attaching source file that reproduces this behavior. > One fix to consider is to call CharsetEncoder.onUnmappableCharacter(CodingErrorAction) in the ReaderInputStream constructor with a value other than the default CodingErrorAction.REPORT. e.g.: > public ReaderInputStream(Reader reader, Charset charset, int bufferSize) { > this.reader = reader; > encoder = charset.newEncoder(); > encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); > ... > By replacing the unmappable character with encoder's default replacement character, this effectively prevents the infinite loop from occurring. I'm not sure if that's the ideal behavior, but it seems fairly consistent with what org.apache.commons.io.output.WriterOutputStream does. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira