Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-780

ReaderInputStream discards some encoding errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.11.0
    • None
    • Streams/Writers
    • 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

          Activity

            People

              Unassigned Unassigned
              Marcono1234 Marcono1234
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: