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

CharSequenceInputStream#reset() behaves incorrectly in case when buffer size is not dividable by data size

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.5
    • Component/s: Streams/Writers
    • Labels:
      None

      Description

      The size effect happens when buffer size of input stream is not dividable by requested data size. The bug is hidden in CharSequenceInputStream#reset() method which should also call (I think) bbuf.limit(0) otherwise next call to CharSequenceInputStream#read() will return the remaining tail which bbuf has accumulated.

      In the attached test case the test fails, if dataSize = 13 (not dividable by 10) and runs OK if dataSize = 20 (dividable by 10).

        Attachments

        1. CharSequenceInputStreamTest.java
          0.8 kB
          Dmitry Katsubo

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dma_k Dmitry Katsubo
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: