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

Sebb commented on IO-365:
-------------------------

Javadoc should always say if null is allowed, and if so, what null means.
The Javadoc should also say if methods can return null, and if so, under which 
circumstances.

But unless null is documented as allowable, the caller should assume it is not 
allowed.
If an NPE then occurs, then the first thing to check the parameters.

For example, try the following:

{code}
char []ca = null;
new String(ca);
{code}

Running the code generates an NPE. 

Note that the Javadoc does not state this; it is assumed.

==

There is one occasion when it might perhaps be worth checking for null (or at 
least documenting the behaviour).
That is where the NPE occurs somewhere remote from the called method. That is 
not the case here.
                
> NullPointerException IOUtils
> ----------------------------
>
>                 Key: IO-365
>                 URL: https://issues.apache.org/jira/browse/IO-365
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.2
>            Reporter: Rustam Matusevic
>            Priority: Trivial
>
> This is normal way to do like this?
> {code}
>     public static InputStream toInputStream(String input) { // if i put null 
> here?
>         byte[] bytes = input.getBytes();
>         return new ByteArrayInputStream(bytes);
>     }
> {code}
> You might to warn users of framework, you know throw some or handle it.

--
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