Skip to content

Instantly share code, notes, and snippets.

@yackx
Created August 26, 2016 19:15
Show Gist options
  • Save yackx/55c148a6294ec30ba5d96a15ae127506 to your computer and use it in GitHub Desktop.
Save yackx/55c148a6294ec30ba5d96a15ae127506 to your computer and use it in GitHub Desktop.
Check for Collection.intersect() bug that affects some Groovy versions
// Check Groovy intersect bug
def checkIntersectBug() {
def foo = [[1], [2], [3]]
def bar = [[2], [3], [4]]
if (foo.intersect(bar).size() != 2) {
println '''Warning!
The version of Groovy that you are running contains a bug on Collection.intersect().
Upgrade to 2.4.7 or later.
See http://stackoverflow.com/questions/35493088/groovy-strange-collectionintersect-behaviour
This program will not function correctly under this version.
Exiting'''
System.exit(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment