commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "SHIN HWEI TAN (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (COLLECTIONS-402) Inconsistent Javadoc comment and code in intersection(List list1,List list2)in org.apache.commons.collections.ListUtils
Date Fri, 30 Mar 2012 03:42:33 GMT
Inconsistent Javadoc comment and code in intersection(List list1,List list2)in org.apache.commons.collections.ListUtils
-----------------------------------------------------------------------------------------------------------------------

                 Key: COLLECTIONS-402
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-402
             Project: Commons Collections
          Issue Type: Bug
          Components: Collection
    Affects Versions: 3.2.1
         Environment: Platform Independent 
            Reporter: SHIN HWEI TAN
             Fix For: 4.0


The Javadoc comment below states that the method "throws NullPointerException if either list
is null". 
    	     /*......
	     * 
	     * @throws NullPointerException if either list is null
	     */
	    public static List intersection(final List list1, final List list2)
	        ..
	    }
However, when called with a null list1 and an empty list2(i.e., "intersection((List)null,
new ArrayList())"), the method executes normally without throwing any exception.

Suggested Fixes:
1. Add code "if (list1 == null) throw NullPointerException();" at the beginning of the method
body.
or
2. Remove "@throws NullPointerException if either list is null" from the Javadoc.
or
3. Change "@throws NullPointerException if either list is null" to "@throws NullPointerException
if list2 is null or (the list2 is non-empty and the list1 is 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