Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.3, 1.6.4, 1.7-beta-1, 1.6.5, 1.7-beta-2
-
None
-
Patch
Description
Bug 3770 fixed setting delegates and resolve strategies on curried closures by passing through to the parent. As was noted in the bug comments, this creates a new issue since we are now changing the original closure which other contexts could be using at the same time. When a closure is curried the original closure should be cloned before its use as the owner.
I've attached a patch to CurriedClosure.java that clones the original closure when a CurriedClosure is created.
void testCurriedClosuresShouldNotAffectParent() {
def orig =
def curriedOrig = orig.curry(1)
// This test currently fails in 1.6.5
assertNotEquals "Curried closures should not reference the original closure curried", orig, curriedOrig.getOwner()
}