更新--这是ColdFusion,https://bugbase.adobe.com/index.cfm?event=bug&id=3546237中的一个bug
我在CF9和NULL指针错误方面遇到了问题,而这些错误似乎在Railo中并不是一个问题。我创建了一个简单的CFC和相关的mxunit测试来确认这一点。
在Railo (4.0.4)上,两个单元测试都通过了。在Cold聚变(9.0.1)上,单元测试getMetaDataBeforeMethodInvocation失败,GetMetaData调用出现空指针错误。
目前,我只能推测,在调用组件中的方法之前,CF9无法访问ObjectLoad之后的完整元数据。是否有人能够更清楚地了解这个问题和/或提供比在执行getMetaData之前调用对象中的方法更好的解决方案?
这是CFC
// NullError.cfc
component {
public NullError function init() {
variables.uuid = CreateUUID();
return this;
}
public string function getUUID() {
return uuid;
}
}及相关单元测试
// NullErrorTest.cfc
component extends='mxunit.framework.TestCase' {
private any function setupTheTests() {
var o = new NullError();
debug(o.getUUID());
// Dump meta data
debug(GetMetaData(o));
// Save and load it, and return
return ObjectLoad(ObjectSave(o));
}
public void function getMetaDataBeforeMethodInvocation() {
var o = setupTheTests();
// Get meta data, and then get uuid, expecting this to ERROR (NULL POINTER)
debug(GetMetaData(o)); // CF FAILS HERE, RAILO DOES NOT
debug(o.getUUID());
}
public void function getMetaDataAfterMethodInvocation() {
var o = setupTheTests();
// Get uuid, and then get meta data, expecting this to be ok
debug(o.getUUID());
debug(GetMetaData(o));
}
}发布于 2013-04-21 00:29:01
我可以在CF 9.0.2和10.0.9中证实这一错误行为。
如果我是你的话我会惹上麻烦的。
repro案例可以根据您的实际情况进行大量简化:
// C.cfc
component {}
<!--- test.cfm --->
<cfscript>
o1 = new C();
writeDump(getMetaData(o1)); // OK
o2 = objectLoad(objectSave(o1));
writeDump(getMetadata(o2)); // breaks
</cfscript> 我不知道该做些什么
https://stackoverflow.com/questions/16103089
复制相似问题