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

An obvious bug in CollectionUtils

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.1
    • 3.2.2
    • Collection
    • windows 7, jdk8. This bug is so obvious so I think it is nothing to do with environment

    • Patch, Important
    • 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

            Unassigned Unassigned
            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