[ 
https://issues.apache.org/jira/browse/IO-356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13585391#comment-13585391
 ] 

Thomas Neidhart commented on IO-356:
------------------------------------

Additional info:

the infinite loop of testIO_356_Loop_UTF16 is due to the fact that the buffer 
size is set to 1, while for UTF-16 encoding, each input character requires at 
least 2 bytes. Thus the input buffer is never consumed as the encoding of the 
input to the output buffer in fillBuffer never succeeds, leading to the 
infinite loop.

We should check the buffer size in the constructor and fail if it is too small 
for the selected charset.
                
> CharSequenceInputStream#reset() behaves incorrectly in case when buffer size 
> is not dividable by data size
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: IO-356
>                 URL: https://issues.apache.org/jira/browse/IO-356
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 2.4
>            Reporter: Dmitry Katsubo
>         Attachments: CharSequenceInputStreamTest.java
>
>
> 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).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to