List equals == operator bug in Groovy

Mon Mar 10 11:50:00 CDT 2008

Eric Anderson and I found this at work when an assertion in a test failed unexpectedly. We had extended ArrayList and overridden its equals(Object) method, but the assert a == b did not call our equals() method (nor did it pass) while assert a.equals(b) behaved as expected.

It turns out there is a bug in the Groovy interpretor version 1.5.4 that calls the ArrayList.equals() method directly instead of the overridden equals method. This may apply to every implementor of the List interface; we are not sure yet.

The thread on the groovy users list is here.

Beware the overloading of equals() if you implement List.