You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "SHIN HWEI TAN (JIRA)" <ji...@apache.org> on 2011/09/22 04:47:26 UTC

[jira] [Updated] (COLLECTIONS-379) Bugs In Javadoc Comment in the CollectionUtils class

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

SHIN HWEI TAN updated COLLECTIONS-379:
--------------------------------------

    Summary: Bugs In Javadoc Comment in the CollectionUtils class  (was: Bug In Javadoc Comment in the CollectionUtils class)

> Bugs In Javadoc Comment in the CollectionUtils class
> ----------------------------------------------------
>
>                 Key: COLLECTIONS-379
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-379
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: System independent
>            Reporter: SHIN HWEI TAN
>              Labels: test
>   Original Estimate: 20m
>  Remaining Estimate: 20m
>
> I came across the following bugs in the Javadoc comments in the method below in the CollectionUtils class:
> 1.
> {quote} 
>    /** 
>      * Selects all elements from input collection which match the given predicate
>      * and adds them to outputCollection.
>      * <p>
>      * If the input collection or predicate is null, there is no change to the 
>      * output collection.
>      * 
>      * @param inputCollection  the collection to get the input from, may be null
>      * @param predicate  the predicate to use, may be null
>      * @param *outputCollection  the collection to output into, may not be null*
>      */
>     public static void select(Collection inputCollection, Predicate predicate, Collection outputCollection) {
> {quote}
> _This method will execute normally when calling select((Collection)null, (Predicate)null, (Collection)null) but the comment clearly states that outputCollection may not be null_
> 2.
> {quote}
>   /** 
>      * Selects all elements from inputCollection which don't match the given predicate
>      * and adds them to outputCollection.
>      * <p>
>      * If the input predicate is <code>null</code>, no elements are added to <code>outputCollection</code>.
>      * 
>      * @param inputCollection  the collection to get the input from, may be null
>      * @param predicate  the predicate to use, may be null
>      * @param *outputCollection  the collection to output into, may not be null*
>      */
>     public static void selectRejected(Collection inputCollection, Predicate predicate, Collection outputCollection) {
> {quote}
> _This method will execute normally when calling selectRejected((Collection)null, (Predicate)null, (Collection)null) but the comment also clearly states that outputCollection may not be null_
> 3.
> {quote}
>   /** 
>      * Transforms all elements from the inputIterator with the given transformer 
>      * and adds them to the outputCollection.
>      * <p>
>      * If the input iterator or transformer is null, there is no change to the 
>      * output collection.
>      *
>      * @param inputIterator  the iterator to get the input from, may be null
>      * @param transformer  the transformer to use, may be null
>      * @param *outputCollection  the collection to output into, may not be null*
>      * @return the outputCollection with the transformed input added
>      * @*throws NullPointerException if the output collection is null*
>      */
>     public static Collection collect(Iterator inputIterator, final Transformer transformer, final Collection outputCollection) {
> {quote}
> _This method will execute normally when calling collect((Iterator)null, (Transformer)null, (Collection)null) but the comment clearly states that NullPointerException will be thrown when the outputCollection is null_
> 4.
> {quote}
>  /** 
>      * Transforms all elements from inputCollection with the given transformer 
>      * and adds them to the outputCollection.
>      * <p>
>      * If the input collection or transformer is null, there is no change to the 
>      * output collection.
>      *
>      * @param inputCollection  the collection to get the input from, may be null
>      * @param transformer  the transformer to use, may be null
>      * @*param outputCollection  the collection to output into, may not be null*
>      * @return the outputCollection with the transformed input added
>      * @*throws NullPointerException if the output collection is null*
>      */
>     public static Collection collect(Collection inputCollection, final Transformer transformer, final Collection outputCollection) {
> {quote}
> _This method will execute normally when calling collect((Collection)null, (Transformer)null, (Collection)null) but the comment clearly states that NullPointerException will be thrown when the outputCollection is null_
> The bugs in the Javadoc comments above could be confusing to the users of the Common Collection library and they could be fixed easily by the developers..
> There are a few ways to fix the:
> 1. Throwing the NullPointerException explicitly when the outputCollection is null.
> 2. Changing the Javadoc comments to include the case where all of the parameters are null.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira