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

CurriedClosure does not clone the parent closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.3, 1.6.4, 1.7-beta-1, 1.6.5, 1.7-beta-2
    • 1.6.6, 1.7-rc-1
    • groovy-jdk
    • 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 =

      { tmp -> println tmp }

      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()
      }

      Attachments

        1. CurriedClosure.patch
          0.9 kB
          James Coleman

        Activity

          People

            blackdrag Jochen Theodorou
            jcoleman James Coleman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: