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

An obvious bug in CollectionUtils

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2.1
    • Fix Version/s: 3.2.2
    • Component/s: Collection
    • Labels:
    • Environment:

      windows 7, jdk8. This bug is so obvious so I think it is nothing to do with environment

    • Flags:
      Patch, Important
    • Docs Text:
      Hide
          /**
           * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
           * method returns a collection containing all the elements in <code>c</code>
           * that are not in <code>remove</code>. The cardinality of an element <code>e</code>
           * in the returned collection is the same as the cardinality of <code>e</code>
           * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
           * case the cardinality is zero. This method is useful if you do not wish to modify
           * the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>.
           *
           * @param collection the collection from which items are removed (in the returned collection)
           * @param remove the items to be removed from the returned <code>collection</code>
           * @return a <code>Collection</code> containing all the elements of <code>collection</code> except
           * any elements that also occur in <code>remove</code>.
           * @throws NullPointerException if either parameter is null
           * @since Commons Collections 3.2
           */
      Show
          /**      * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this      * method returns a collection containing all the elements in <code>c</code>      * that are not in <code>remove</code>. The cardinality of an element <code>e</code>      * in the returned collection is the same as the cardinality of <code>e</code>      * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which      * case the cardinality is zero. This method is useful if you do not wish to modify      * the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>.      *      * @param collection the collection from which items are removed (in the returned collection)      * @param remove the items to be removed from the returned <code>collection</code>      * @return a <code>Collection</code> containing all the elements of <code>collection</code> except      * any elements that also occur in <code>remove</code>.      * @throws NullPointerException if either parameter is null      * @since Commons Collections 3.2      */

      Description

      In CollectionUtils.java:
      Line number: 1121

      /**

      • Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
      • method returns a collection containing all the elements in <code>c</code>
      • that are not in <code>remove</code>. The cardinality of an element <code>e</code>
      • in the returned collection is the same as the cardinality of <code>e</code>
      • in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
      • case the cardinality is zero. This method is useful if you do not wish to modify
      • the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>.
      • @param collection the collection from which items are removed (in the returned collection)
      • @param remove the items to be removed from the returned <code>collection</code>
      • @return a <code>Collection</code> containing all the elements of <code>collection</code> except
      • any elements that also occur in <code>remove</code>.
      • @throws NullPointerException if either parameter is null
      • @since Commons Collections 3.2
        */
        public static Collection removeAll(Collection collection, Collection remove) { return ListUtils.retainAll(collection, remove); }

        The method should call ListUtils.removeAll(Collection collection, Collection remove) instead of calling ListUtils.retailAll(collection,remove)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              samray samray leung
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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