commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (COLLECTIONS-379) Bugs In Javadoc Comment in the CollectionUtils class
Date Thu, 26 Jul 2012 21:20:34 GMT

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

Thomas Neidhart resolved COLLECTIONS-379.
-----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0

Fixed in r1366204.
                
> 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
>             Fix For: 4.0
>
>   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.
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

        

Mime
View raw message