Skip to main content
Known Participant
April 1, 2011
Question

how is cflock and cffinally guaranteed?

  • April 1, 2011
  • 1 reply
  • 587 views

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

This topic has been closed for replies.

1 reply

Inspiring
April 2, 2011

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