Inconsistent Javadoc comment and code for prototypeFactory(T) in
org.apache.commons.collections.FactoryUtils
------------------------------------------------------------------------------------------------------------
Key: COLLECTIONS-388
URL: https://issues.apache.org/jira/browse/COLLECTIONS-388
Project: Commons Collections
Issue Type: Bug
Components: Collection
Affects Versions: 4.0, 4.x
Environment: Platform independent
Reporter: SHIN HWEI TAN
The Javadoc comment below states that the method "throws
IllegalArgumentException if the prototype is null":
/**
..
* @param prototype the object to clone each time in the factory
* @return the <code>prototype</code> factory
* @throws IllegalArgumentException if the prototype is null
* @throws IllegalArgumentException if the prototype cannot be
cloned
*/
public static <T> Factory<T> prototypeFactory(T prototype) {
return PrototypeFactory.<T>prototypeFactory(prototype);
}
However, the method returns a NULL_INSTANCE object instead of throwing
IllegalArgumentException when called with null.
Suggested Fixes:
1. Change "@throws IllegalArgumentException if the prototype is null" and
"@return" to "@return NULL_INSTANCE if the prototype is null".
or
2. Remove the entire "throws IllegalArgumentException if the prototype 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