ColdFusion 10.0  -  Bug 3218452

Created on Tuesday, June 19, 2012

Login for more options

Title

CFThread fails when called from Custom Tags without joining back to parent process

Description

Problem Description:

When a cfthread tag is used inside a custom tag, if the thread is not joined back to the calling custom tag, then the thread does not property execute.

Steps to Reproduce:

Create the following three files, all in the same directory.

Application.cfc:

component
{
this.name = "CFThreadCustomTagTest";
}

ThePage.cfm:

<cfthread action="run" name="ThreadTestInPage">
<cflog log="Application" text="The thread in the page successfully ran" type="information" />
</cfthread>
<cf_ThreadTag />

ThreadTag.cfm:

<cfif thisTag.ExecutionMode EQ "start">
<cfthread action="run" name="ThreadTest">
<cflog log="Application" text="The thread within the tag successfully ran" type="information" />
</cfthread>
</cfif>

Actual Result:

When viewing the logs, I see the following entries:

"Severity","ThreadID","Date","Time","Application","Message"
"Information","ajp-bio-8012-exec-1","06/19/12","07:18:11",,"C:\ColdFusion10\cfusion\logs\application.log initialized"
"Information","cfthread-11","06/19/12","07:18:15","CFTHREADCUSTOMTAGTEST","The thread in the page successfully ran"
"Error","cfthread-9","06/19/12","07:18:15",,"THREADTEST: Variable _cffunccfthread_cfThreadTag2ecfm16902001291 is undefined. "

Expected Result:

I expect to see two log entries, one for the thread processing in the page, and one for the thread processing in the tag.

Any Workarounds:

If I change ThreadTag.cfm to the following code:

<cfif thisTag.ExecutionMode EQ "start">
<cfthread action="run" name="ThreadTest">
<cflog log="Application" text="The thread within the tag successfully ran" type="information" />
</cfthread>
<cfthread action="join" name="ThreadTest" timeout="10" />
<cfdump var="#cfthread#">

</cfif>

Then I get the two log entries that I expect. However, I need to be able to run a thread without waiting for it to finish.

Test Configuration

My Hardware and Environment details:

Windows Server 2008, IIS 7 using the default ColdFusion 10 install. I have updated the JVM to u32 in order to be compatible with Microsoft's JDBC SQL Server driver. You can see my development server settings here:

https://dl.dropbox.com/u/2586403/serversettings.pdf

I see this on three separate ColdFusion 10 installations, and can reproduce the problem every single time.

App Language(s) English
OS Language(s) English
Platform(s) Win 2008 Server R2 64 bit
Browser(s) Browsers All

Notes (5)

  • JNokes

    2:00:34 PM GMT+00:00 Apr 8, 2014

    I am seeing this error in CF10 update 13 when I call <cfthread> from inside a custom tag which is called from a CFC.

  • Rupesh Kumar

    1:01:49 AM GMT+00:00 Nov 29, 2013

    @ccapodilupo This was fixed in CF 10 update 1. Could you please share your repro case so that we can investigate?

  • ccapodilupo

    3:16:52 PM GMT+00:00 Nov 19, 2013

    We are still seeing this issue in CF 10 update 12. Why was this bug closed?

  • DanielShort

    8:59:34 AM GMT+00:00 Jun 19, 2012

    With further testing, I've found that if I move the thread logic into a CFC, and then run a CFC method from within the Custom Tag, that my thread runs and logs successfully. I change my custom tag to this:

    <cfif thisTag.ExecutionMode EQ "start">
    <cfset myCFC = CreateObject("component", "myCFC") />
    <cfset myCFC.runThread() />

    </cfif>

    And create myCFC like so:

    <cfcomponent output="false">

    <cffunction name="runThread" access="public" output="false" returntype="void">
    <cfthread action="run" name="ThreadTest#CreateUUID()#">
    <cflog log="Application" text="The thread within the CFC successfully ran" type="information" />
    </cfthread>

    </cffunction>
    </cfcomponent>

    This allows the thread to run. So it is definitely a problem with thread running directly in the context of a custom tag exection.

  • DanielShort

    8:29:41 AM GMT+00:00 Jun 19, 2012

    You can also see me working through this problem on StackOverflow here:

    http://stackoverflow.com/questions/11089901/undefined-error-when-using-cfthread-in-custom-tags-in-coldfusion-10

Duplicate ID
Reported By DanielShort

Status

State Closed
Status Fixed
Reason

Importance

Priority 4-Very High
Frequency All users will encounter
Failure Type Non Functioning
Product Area Language

Build

Found In Build Final
Fixed In Build 282610

Attachments (0)

No Files Attached

Votes (2)

  • Adam Cameron.

    5:30:21 AM GMT+00:00 Jun 20, 2012

    Yep, I can replicate too.

  • Malliard

    8:36:34 AM GMT+00:00 Jun 19, 2012

    I was able to reproduce this using files provided by Dan S.

Your session has expired! Click to login
Current form data will be preserved

Cancel