[ 
https://issues.apache.org/jira/browse/IO-174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gwenaƫl Le Roux updated IO-174:
-------------------------------

    Attachment: IO-174.patch

Here is a patch that makes the CharSequenceReader compatible with the 
java.io.Reader API contract. 
WARNING: There are side effects. The close method does not reset the position 
anymore and the methods read, mark, ready, reset and skip throw now a 
IOException when the reader is closed.

A java.io.IOException exception has been added to the following methods: 
mark(int), read(), read(char[],int,int), ready(), reset(), skip(long). The 
method ready() has been also implemented.
The following methods of CharSequenceReaderTest have been updated: testClose(), 
testMark(), testRead(), testReadCharArray(), testSkip().
The following methods have been created: testReset(), testReady().

> CharSequenceReader does not obey Reader contract and throw IOExceptions if 
> read when closed
> -------------------------------------------------------------------------------------------
>
>                 Key: IO-174
>                 URL: https://issues.apache.org/jira/browse/IO-174
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 1.4
>            Reporter: Douglas Hauge
>         Attachments: IO-174.patch
>
>
> In the Java specs for 
> [*java.io.Reader.close()*|http://java.sun.com/j2se/1.5.0/docs/api/java/io/Reader.html#close()],
>  it states
> {panel}
> Once a stream has been closed, further read(), ready(), mark(), or reset() 
> invocations will throw an IOException
> {panel}
> However, the *org.apache.commons.io.input.CharSequenceReader* does not do 
> this, but instead resets the file back to the start when it is closed. This 
> causes problems when passing this reader to some libraries (albeit admittedly 
> poorly written ones) that rely on *read* throwing an *IOException* after the 
> reader has been closed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to