Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.8.0
-
None
Description
org.apache.commons.io.input.ReaderInputStream constructed with a CharsetEncoder with CodingErrorAction.REPORT does not throw exceptions when unmappable or malformed input is encountered. And in some cases can even enter infinite loops.
Example:
CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder().onMalformedInput(CodingErrorAction.REPORT); try (InputStream in = new ReaderInputStream(new StringReader("\uD800aa"), encoder, 2)) { in.read(); }
The reason for this is that the class does not check CoderResult.isError() and then call CoderResult.throwException().
It would also be good to improve the documentation of the constructors taking a Charset or charset name to describe that they replace unmappable or malformed input with the default replacement character.
Attachments
Issue Links
- relates to
-
IO-277 ReaderInputStream enters infinite loop when it encounters an unmappable character
- Closed