Uploaded image for project: 'Clover'
  1. Clover
  2. CLOV-1547

The Grails' @Transactional annotation conflicts with Clover's AST transformations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Medium
    • 4.0.2
    • 3.3.0
    • Grails Plugin, Groovy
    • None

    Description

      The @Transactional annotation is the new Grails-y way of controlling transactional behavior in a service. It uses an AST transformation to essentially wrap public methods (if added to the class) in a GrailsTransactionTemplate. So you get code that looks like this:

      public void reject(Invoice invoice)
        {
          Reference invoice = new Reference(invoice);
          CallSite[] arrayOfCallSite = $getCallSiteArray();
          GrailsTransactionAttribute $transactionAttribute = (GrailsTransactionAttribute)ScriptBytecodeAdapter.castToType(arrayOfCallSite[9].callConstructor(GrailsTransactionAttribute.class), GrailsTransactionAttribute.class);
          GrailsTransactionTemplate $transactionTemplate = (GrailsTransactionTemplate)ScriptBytecodeAdapter.castToType(arrayOfCallSite[10].callConstructor(GrailsTransactionTemplate.class, this.transactionManager, $transactionAttribute), GrailsTransactionTemplate.class);
          $transactionTemplate.execute(new _reject_closure5(this, invoice));
        }
      

      The real body of the method is in the reject_closure5, which ends up calling a method named "$tt_reject(...)".

      Clover doesn't realize that the code originally under the reject method has essentially been relocated to the $tt__reject method.

      Given that @Transactional is a core part of Grails (starting in 2.3, I believe) and the recommended way to control transactions going forward, this is probably something that should be addressed in Clover core.

      Attachments

        Activity

          People

            mparfianowicz Marek Parfianowicz
            mparfianowicz Marek Parfianowicz
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: