1 Reply Latest reply on Apr 2, 2011 2:45 AM by Adam Cameron.

    how is cflock and cffinally guaranteed?

    tinu8805

      Consider this

       

      <cflock ...>

         <cftry>

            ...

         <cfcatch>

            <cfexit method="exittemplate">

         </cfcatch>

         </cftry>

      </cflock>

       

      Will the </cflock>-related code execute despite the <cfexit> or maybe even <cfabort>?

       

      Unfortunately, one cannot write

       

      <cftry>

         <cflock ...>

            ...

      <cfcatch>

         <cfexit method="exittemplate">

      </cfcatch>

      <cffinally>

         </cflock>

      </cffinally>

      </cftry>

       

       

      Or will this do what I want, regardless of whatever and where the exception is thrown?

      <cftry>

         <cflock ...>

            ...

         </cflock>

      <cfcatch>

         <cfexit method="exittemplate">

      </cfcatch>

      </cftry>


      Anyone to make this more clear to me?
      Thank you
      Martin

        • 1. Re: how is cflock and cffinally guaranteed?
          Adam Cameron. Level 5

          My instinct is that the first approach will work fine: CF needs to be clever enough to clear locks even when the closing CFLOCK tag is never encountered. This would be pretty easy for you to test, really.

           

          Either the first or third approach will work: if all that's happening in the CFCATCH is the CFEXIT call, then you don't need to have that in the lock anyhow: there's nothing that needs locking.

           

          If there was code in the CFCATCH that needed to be within the same lock as the rest of the code, then the first approach would be necessary.

           

          --

          Adam