【问题标题】:cfthread object empty inside of a cfthread tag in Lucee 5.2Lucee 5.2 中 cfthread 标记内的 cfthread 对象为空
【发布时间】:2019-10-09 04:01:55
【问题描述】:

在 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,以及包含 test_thread 状态的 checkTestThread.txt。

在这两个版本中,cfdump 都返回 cfthread 对象。第一个转储包含两个线程,第二个转储只包含预期的 test_thread 对象。

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

【问题讨论】:

    标签: cfml lucee


    【解决方案1】:

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

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

    原因是这不再适用于 Lucee,因为我们添加了支持 在线程内部有线程,从那时起“cfthread”只显示 当前线程的子线程,在树中(参见键“childThreads” 在“cfthread”内)。我们无法在一个级别上显示所有线程 造成混乱,因为我们会同时显示线程树 时间。

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

    在我的代码中更改以下内容:&lt;cfset test_thread_status = cfthread['test_thread'].status /&gt;&lt;cfset test_thread_status = threadData()['test_thread'].status /&gt; 修复错误并正确返回同级线程的状态。

    更多信息:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-15
      • 1970-01-01
      • 2017-01-11
      相关资源
      最近更新 更多