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

Intersect returns an empty list when the contents of the compared Collections are Maps

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.11, 2.4.5
    • Fix Version/s: 2.4.7
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      Mac OS X 10.9.5
      Oracle Java 1.8.0_60

      Description

      When I compare two lists with intersect and both lists contain maps I do not get any results, even if the contents are equivalent. The test fails in Groovy 2.3.11, but passes in 2.3.7.

      import org.junit.Test
      
      class IntersectTest {
          @Test
          void testIntersect() {
              def list1 = [[language: 'Java'], [language: 'Groovy'], [language: 'Scala']]
              def list2 = [[language: 'Groovy'], [language: 'JRuby'], [language: 'Java']]
              def intersection = list1.intersect(list2)
      
              assert list1[0] == list2[2] // proves that there should be intersecting values
              println "Intersection: $intersection"
              assert intersection == [[language: 'Groovy'], [language: 'Java']]
          }
      }
      

      The intersect call returns an empty list in 2.3.11, resulting in the following output:

      Intersection: []
      
      Assertion failed: 
      
      assert intersection == [[language: 'Groovy'], [language: 'Java']]
             |            |
             []           false
      

        Issue Links

          Activity

          Hide
          lari.hotari@sagire.fi Lari Hotari added a comment -
          Show
          lari.hotari@sagire.fi Lari Hotari added a comment - problem might be caused by https://github.com/apache/incubator-groovy/commit/4a5bb22d change ( GROOVY-7267 ).
          Hide
          paulk Paul King added a comment -

          possibly related to disjoint issue

          Show
          paulk Paul King added a comment - possibly related to disjoint issue
          Hide
          paulk Paul King added a comment -

          Should be fixed as part of GROOVY-7530 (PR#276)

          Show
          paulk Paul King added a comment - Should be fixed as part of GROOVY-7530 (PR#276)
          Hide
          paulk Paul King added a comment -

          merged above mentioned PR

          Show
          paulk Paul King added a comment - merged above mentioned PR

            People

            • Assignee:
              paulk Paul King
              Reporter:
              jguertin-gls Justin Guertin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development