You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Hudson (Commented) (JIRA)" <ji...@apache.org> on 2012/04/09 19:35:17 UTC

[jira] [Commented] (COLLECTIONS-400) Inconsistent Javadoc comment and code in addIgnoreNull(Collection, T) in org.apache.commons.collections.CollectionUtils

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

Hudson commented on COLLECTIONS-400:
------------------------------------

Integrated in commons-collections #16 (See [https://builds.apache.org/job/commons-collections/16/])
    [COLLECTIONS-400] Added missing null check, thanks to Shin Hwei Tan. (Revision 1311344)

     Result = SUCCESS
tn : http://svn.apache.org/viewvc/?view=rev&rev=1311344
Files : 
* /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/CollectionUtils.java

                
> Inconsistent Javadoc comment and code in addIgnoreNull(Collection<T>, T) in org.apache.commons.collections.CollectionUtils
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-400
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-400
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.2.1
>         Environment: Platform independent
>            Reporter: SHIN HWEI TAN
>              Labels: javadoc
>             Fix For: 4.0
>
>   Original Estimate: 0.05h
>  Remaining Estimate: 0.05h
>
> The Javadoc comment below states that the method "throws NullPointerException if the collection is null". 
>     	    /**
> 	       .....
> 	     * @param collection  the collection to add to, must not be null
> 	     * @param object  the object to add, if null it will not be added
> 	     * @return true if the collection changed
> 	     * @throws NullPointerException if the collection is null
> 	     */
> 	    public static <T> boolean addIgnoreNull(Collection<T> collection, T object) {
> 	        return (object != null && collection.add(object));
> 	    }
> However, when called with an null collection and a null object (i.e., "addIgnoreNull((Collection)null, null)"), the method executes normally without throwing any exception.
> Suggested Fixes:
> 1. Add code "if (collection == null) throw NullPointerException();" at the beginning of the method body.
> or
> 2. Remove "@throws NullPointerException if the collection is null" from the Javadoc.
> or
> 3. Change "@throws NullPointerException if the collection is null" to "@throws NullPointerException if the collection is null and the object is non-null)".

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira