Lucee 5.2 中 cfthread 标签内的 cfthread 对象为空

cfthread object empty inside of a cfthread tag in Lucee 5.2

在 Lucee v5.2.9.31 中,当我从 cfthread 对象请求 test_thread 线程的状态时,以下代码在 checkTest 线程内部抛出错误。我得到的错误是 key [test_thread] doesn't exist

<cfthread action="run" name="test_thread">
    <cfloop index='i' from='1' to='50'>
        <cffile action="append" file="./test_thread.txt" addNewLine="yes" output="Index: #i#" />
        <cfset sleep(500) />
    </cfloop>
</cfthread>

<cfthread action="run" name="checkTest">
    <cfset test_thread_complete = false />
    <cfloop condition="test_thread_complete eq false">
        <cfset test_thread_status = cfthread['test_thread'].status />

        <cffile action="append" file="./checkTestThread.txt" addNewLine="yes" output="#test_thread_status#" />

        <cfif test_thread_status eq 'COMPLETED'>
            <cfset test_thread_complete = true />
        </cfif>
        <cfset sleep(1000) />
    </cfloop>
</cfthread>

<cfdump var="#cfthread#" />
<cfdump var="#cfthread['test_thread']#" />

然而,在旧版本的 Lucee (v4.5.5.015) 中,代码按预期工作并生成了 2 个文件:test_thread.txt 具有递增索引,checkTestThread.txt 包含状态共 test_thread.

在两个版本中,cfdumps return cfthread 对象。第一个转储包含两个线程,第二个转储仅包含预期的 test_thread 对象。

这是 Lucee 5 中的错误还是代码利用了 Lucee/Railo 早期版本中的错误?

这是由对 Lucee 进行的更新引起的。

根据 Michael Offner(Lucee 的维护者)的说法:

The reason is this no longer works in Lucee, because we added support of having threads inside threads, since then "cfthread" only shows the children of the current thread, in a tree (see key "childThreads" inside "cfthread"). We cannot show all threads on one level that would create a mess, because we would show the tree of threads at the same time.

问题已在 v5.3.4.37 中修复,但是需要更新代码,因为他们的解决方案添加了一个 threadData 函数,该函数 returns 根 cfthread 对象。

在我的代码中更改以下内容:<cfset test_thread_status = cfthread['test_thread'].status /><cfset test_thread_status = threadData()['test_thread'].status /> 修复了错误并正确 returns 兄弟线程的状态。

更多信息: