1

For years, I've been using the following code across multiple ColdFusion environments:

<cfthread 
    action                  = "run" 
    name                    = "#Local.cachedFilename#"
    src                     = "#Arguments.src#"
>

    <!--- Process  image --->
    <cfset Local.objImage = This.processImage(
        src                     = Arguments.src
    ) />

</cfthread>

I've come to reuse my component in a different environment today and for the first time I've hit an error, that Arguments.src does not exist inside the thread.

A bit of Googling returned an answer, I should be using the attributes scope inside a thread... so the ProcessImage call makes use of Attributes.src instead of Arguments.src.

This works fine. All is well. But I'm confused.
I wrote this code for Railo. It worked fine. I ported it over to CF10, it worked fine. I ran it on CF11. It worked fine. The first time I've come across an error is on a particular box, also running CF10.

So my question is - was there an update somewhere, or is there some particular set of circumstances, that would allow me to use the arguments scope inside a CFThread? Essentially if I'm supposed to be using the attributes scope, how have I had this working fine for years?!

Gary Stanton
  • 1,435
  • 12
  • 28
  • Perhaps what is happening is that after the thread has spawned, the function that called it completes and the variables defined in the function are released, so when the thread starts executing, `ARGUMENTS.src` no longer exists. This is why using the `ATTRIBUTES` scope is necessary: Keeps the thread self-contained and no threading issues – beloitdavisja Apr 22 '16 at 12:57

1 Answers1

0

CFThread is a tag, not a function call. It therefore has attributes, not arguments. It would appear that Railo/Lucee for some reason incorrectly make the attributes available in an arguments scope as well. Adobe's behavior is correct IMO and you just got away with it by luck in the past on Railo.

Brad Wood
  • 3,863
  • 16
  • 23
  • 1
    Thanks Brad! It's a four year old question, and on your own recommendation I now use CFConcurrent in place of most of my thread calls, because it's awesome... but still, good to clear that up! ;) – Gary Stanton Sep 14 '20 at 22:51