groovy

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

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0, 1.1-beta-1, 1.1-beta-2
  • Fix Version/s: 1.1-rc-1
  • Component/s: groovy-jdk
  • Labels:
    None
  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    2

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.

  1. DefaultGroovyMethods.java
    23/Jul/07 12:11 PM
    261 kB
    Hauke Plambeck
  2. MinusTest.groovy
    23/Jul/07 12:11 PM
    2 kB
    Hauke Plambeck

Activity

Hide
Alexandru Popescu added a comment -

Committed in r.8376. Thanks.

./alex

.w( the_mindstorm )p.

Show
Alexandru Popescu added a comment - Committed in r.8376. Thanks. ./alex – .w( the_mindstorm )p.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: