You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Rob Spoor <ap...@icemanx.nl> on 2020/07/08 19:49:08 UTC

[IO] CharSequenceReader improvements

Hi,

I was replacing my own copy of CharSequenceReader with the one from 
commons-io, but I had some test failures. I found out that there were 
two reasons:

* It doesn't override ready(), and therefore always returns false, even 
if there are still characters to be read. That's not incorrect according 
to the specification, but it's better to return true instead.
Pull request: https://github.com/apache/commons-io/pull/122

* skip(long) currently returns -1 if the stream has ended. However, that 
violates the contract of Reader.skip(long), which says the method should 
return the number of characters actually skipped. At the end of the 
stream, that's not -1 but 0.
Pull request: https://github.com/apache/commons-io/pull/123


Kind regards,

Rob

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [IO] CharSequenceReader improvements

Posted by Rob Spoor <ap...@icemanx.nl>.
Thanks!

On 10/07/2020 14:25, Gary Gregory wrote:
> Thanks Rob, I merged both PRs to master.
> 
> Gary
> 
> On Wed, Jul 8, 2020 at 3:49 PM Rob Spoor <ap...@icemanx.nl> wrote:
> 
>> Hi,
>>
>> I was replacing my own copy of CharSequenceReader with the one from
>> commons-io, but I had some test failures. I found out that there were
>> two reasons:
>>
>> * It doesn't override ready(), and therefore always returns false, even
>> if there are still characters to be read. That's not incorrect according
>> to the specification, but it's better to return true instead.
>> Pull request: https://github.com/apache/commons-io/pull/122
>>
>> * skip(long) currently returns -1 if the stream has ended. However, that
>> violates the contract of Reader.skip(long), which says the method should
>> return the number of characters actually skipped. At the end of the
>> stream, that's not -1 but 0.
>> Pull request: https://github.com/apache/commons-io/pull/123
>>
>>
>> Kind regards,
>>
>> Rob
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [IO] CharSequenceReader improvements

Posted by Gary Gregory <ga...@gmail.com>.
Thanks Rob, I merged both PRs to master.

Gary

On Wed, Jul 8, 2020 at 3:49 PM Rob Spoor <ap...@icemanx.nl> wrote:

> Hi,
>
> I was replacing my own copy of CharSequenceReader with the one from
> commons-io, but I had some test failures. I found out that there were
> two reasons:
>
> * It doesn't override ready(), and therefore always returns false, even
> if there are still characters to be read. That's not incorrect according
> to the specification, but it's better to return true instead.
> Pull request: https://github.com/apache/commons-io/pull/122
>
> * skip(long) currently returns -1 if the stream has ended. However, that
> violates the contract of Reader.skip(long), which says the method should
> return the number of characters actually skipped. At the end of the
> stream, that's not -1 but 0.
> Pull request: https://github.com/apache/commons-io/pull/123
>
>
> Kind regards,
>
> Rob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>