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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Medium
    • 4.0.2
    • Affects Version/s: 3.3.0
    • Component/s: Grails Plugin, Groovy
    • None

      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.

        1. clover-4.0.2-plugin.xml
          2 kB
          Marek Parfianowicz
        2. grails-clover-4.0.2.zip
          10 kB
          Marek Parfianowicz

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

              Created:
              Updated:
              Resolved: