我在我的应用程序范围中放置了一个组件,以便它在所有请求之间共享,并且它包括一个 cfm 模板:
<cfcomponent output="false">
<cffunction name="run" output="false" returntype="void">
<cfset var tmp = false/>
<cftry>
<cfinclude template="inc.cfm"/>
<cfcatch>
<cffile action="append"
file="#ExpandPath("error.log")#"
output="ERROR: #cfcatch.message#"/>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
包含的模板只是创建一个数组并检查数组长度是否应该是它应该是什么,如果不是它写入error.log
文件:
<cfset tmp = [
"one",
"two",
"three"
]/>
<cfif ArrayLen(tmp) neq 3>
<cffile action="append"
file="#ExpandPath("error.log")#"
output="Length = #ArrayLen(tmp)#"/>
</cfif>
如果我然后在它上运行负载(100 个并发线程),我的error.log
文件中会出现以下项目......
ERROR: element at position 3 of array variable "___IMPLICITARRYSTRUCTVAR0" cannot be found.
Length = 0
Length = 2
注意我在 Java 1.7.0_09 之上使用 ColdFusion 9.0.1.274733。我已经在同一个 JRE 上测试了 Railo,它工作正常。
附加以下也会导致问题,将变量更改为结构并在范围内tmp
添加一个未在任何地方引用的随机项...variables
<cfcomponent output="false">
<!---
Some random variable that does nothing with the exception
of being the facilitator of my eternal pain
--->
<cfset variables.t = {}/>
<cffunction name="run" output="false" returntype="void">
<cfset var tmp = {}/>
<cftry>
<cfinclude template="inc2.cfm"/>
<cfcatch>
<cffile action="append"
file="#ExpandPath("error.log")#"
output="ERROR: #cfcatch.message#"/>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
其中包括一个模板,与第一个非常相似,看起来像这样......
<cfset tmp.arr = [
"one",
"two",
"three"
]/>
<cfif ArrayLen(tmp.arr) neq 3>
<cffile action="append"
file="#ExpandPath("error.log")#"
output="Length = #ArrayLen(tmp.arr)#"/>
</cfif>
如果您删除variables
范围内的项目,它工作正常。如果您转储#variables#
并#local#
在模板中,一切都在您期望的位置。
(评论更新)
我已经将此问题作为错误 #3352462 提出