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

Thomas Neidhart resolved COLLECTIONS-400.
-----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0

Thanks for the report. I have added the missing null check in r1311344.
                
> 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

        

Reply via email to