commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary D. Gregory (Closed) (JIRA)" <>
Subject [jira] [Closed] (IO-277) ReaderInputStream enters infinite loop when it encounters an unmappable character
Date Mon, 10 Oct 2011 15:49:30 GMT


Gary D. Gregory closed IO-277.

Closing, we released version 2.1.
> ReaderInputStream enters infinite loop when it encounters an unmappable character
> ---------------------------------------------------------------------------------
>                 Key: IO-277
>                 URL:
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 2.0.1
>            Reporter: Mike Thomas
>            Assignee: Niall Pemberton
>             Fix For: 2.1
>         Attachments:
> The[] 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 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.
> 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 does.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message