Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.11.0
-
None
-
None
Description
Description
org.apache.commons.io.input.ReaderInputStream discards encoder errors in some cases instead of properly rethrowing them.
The underlying issue is that lastCoderResult is re-assigned before it has been checked for errors and overflow (link to code).
This was originally mentioned in pull request #293.
Example
The read() call in the following example should throw an exception, but currently it erroneously returns -1.
// Encoder which throws on malformed or unmappable input CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder(); ReaderInputStream in = new ReaderInputStream(new StringReader("\uD800"), encoder); // BUG: This should have thrown an exception because the input is malformed System.out.println("Read: " + in.read());
Attachments
Issue Links
- relates to
-
IO-714 ReaderInputStream does not call CharsetEncoder.flush(...)
- Resolved