Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1995

minus(List self, Collection removeMe) throws IllegalStateException for dupplicate values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0, 1.1-beta-1, 1.1-beta-2
    • 1.1-rc-1
    • groovy-jdk
    • None
    • Patch

    Description

      DefaultGroovyMethods.minus(List, Collection removeMe) and DefaultGroovyMethods.NumberAwareComparator have two problems.<br>

      1. dupplicate values that are not Comparable cause IllegalStateExceptions
      <code>
      def a = new Object()
      // throws IllegalStateException
      assert [] == [ a ] - [ a, a ]
      </code><br>
      2. null values are not removed from a List
      <code>
      // fails
      assert [] == [ null ] - [ null ]
      </code><br>
      I have attached a unit test and a fix based on the groovy-1.1-beta-2 source.

      Attachments

        1. MinusTest.groovy
          2 kB
          Hauke Plambeck
        2. DefaultGroovyMethods.java
          261 kB
          Hauke Plambeck

        Activity

          People

            alexpopescu Alexandru Popescu
            hplambeck Hauke Plambeck
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: