You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2022/06/20 18:32:00 UTC

[jira] [Resolved] (IO-564) The rules of ByteArrayOutputStream.write are not documented.

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

Gary D. Gregory resolved IO-564.
--------------------------------
    Fix Version/s: 2.12.0
       Resolution: Fixed

Pick up Javadoc from super for override write() methods in AbstractByteArrayOutputStream and ByteArrayOutputStream.

> The rules of ByteArrayOutputStream.write are not documented.
> ------------------------------------------------------------
>
>                 Key: IO-564
>                 URL: https://issues.apache.org/jira/browse/IO-564
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 2.6
>            Reporter: Hao Zhong
>            Priority: Major
>             Fix For: 2.12.0
>
>
> When I call the ByteArrayOutputStream.write method, it returns exceptions. Its API document  is not quite useful, since it does not define any rules. From the thrown exceptions, I cannot get any useful information either. Until I read the code, I understand its usage:
> {code}
>  public void write(final byte[] b, final int off, final int len) {
>  if ((off < 0)
>                 || (off > b.length)
>                 || (len < 0)
>                 || ((off + len) > b.length)
>                 || ((off + len) < 0)) {
>             throw new IndexOutOfBoundsException();
>         } else if (len == 0) {
>             return;
>         }
> ...
> }
> {\code}
> Would you please explicitly introduce the rules in the doucment? Or, would you please add more messages to the thrown exception? Both ways can make the API easier to understand.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)