Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-384

Inconsistent Javadoc comment and code for synchronizedMap(Map) in org.apache.commons.collections.MapUtils

    Details

      Description

      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".

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              shinhwei SHIN HWEI TAN
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 5m
                5m
                Remaining:
                Remaining Estimate - 5m
                5m
                Logged:
                Time Spent - Not Specified
                Not Specified