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-384) Inconsistent Javadoc comment and code for synchronizedMap(Map) in org.apache.commons.collections.MapUtils
Date Wed, 26 Oct 2011 20:23:32 GMT
Inconsistent Javadoc comment and code for synchronizedMap(Map) in org.apache.commons.collections.MapUtils
---------------------------------------------------------------------------------------------------------

                 Key: COLLECTIONS-384
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-384
             Project: Commons Collections
          Issue Type: Bug
          Components: Collection
    Affects Versions: 3.2, 3.1, 3.0
         Environment: Platform independent
            Reporter: SHIN HWEI TAN
            Priority: Minor


The Javadoc comment below states that the method "throws IllegalArgumentException if the map
is null":
    /**
     ...
     * @param map  the map to synchronize, must not be null
     * @return a synchronized map backed by the given map
     * @throws IllegalArgumentException  if the map is null
     */
    public static Map synchronizedMap(Map map) {
        return Collections.synchronizedMap(map);
    }

However, the method throws NullPointerException instead of IllegalArgumentException when called
with null.

Suggested Fixes:
1. Add code "if (map == null) throw IllegalArgumentException();" at the beginning of the method
body.
or
2. Change "@throws IllegalArgumentException  if the map is null" to "@throws NullPointerException
 if the map is null".
or
3. Remove the entire "@throws IllegalArgumentException  if the map 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