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

Inconsistent Javadoc comment and code in removeAll(Collection<E>, Collection<?>) in org.apache.commons.collections.ListUtils

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 3.2.1
    • Fix Version/s: None
    • Component/s: Collection
    • Labels:

      Description

      The Javadoc comment below states that the method "throws NullPointerException if either parameter is null".
      /*......

      • @throws NullPointerException if either parameter is null
        */
        public static <E> List<E> removeAll(Collection<E> collection, Collection<?> remove) { .. }

        However, when called with two null collections (i.e., "removeAll((Collection)null, (Collection)null)"), the method executes normally without throwing any exception.

      Suggested Fixes:
      1. Add code "if (collection == null) throw NullPointerException();" at the beginning of the method body.
      or
      2. Remove "@throws NullPointerException if either parameter is null" from the Javadoc.
      or
      3. Change "@throws NullPointerException if either parameter is null" to "@throws NullPointerException if the first collection is null or (the first collection is non-empty and the second collection is null)".

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.05h
                0.05h
                Remaining:
                Remaining Estimate - 0.05h
                0.05h
                Logged:
                Time Spent - Not Specified
                Not Specified