Details
Description
Seems like @Immutable classes do not do defensive copying of the collection provided into constructor:
@Immutable final class Person { String name List<String> address } def myAddress = ["Line1","Line2"] def person = new Person(name:"Name", address:myAddress) assert person.address == ["Line1","Line2"] myAddress << "Line3" assert myAddress == ["Line1","Line2","Line3"] assert person.address == ["Line1","Line2"] //<- fails
Workaround is to use ArrayList not List as the type for address.