Coldfusion - runAsnyc 方法不允许实例化 Bean

Coldfusion - runAsnyc method not allowing the instantiation of Beans

提问人:user1002794 提问时间:10/3/2023 最后编辑:user1002794 更新时间:10/3/2023 访问量:38

问:

我的基本示例错误与空点异常错误。此错误仅在我们实例化基本 Bean 时才会显现。在 Async 中实例化 bean 是否有某种限制?

Coldfusion 2018 - V 2018.0.08.330106

Bean 代码

<cfcomponent displayname="TestBean" hint="I model a single TestBean." output="false">

    <!--- CONSTRUCTOR --->
    <cffunction name="init" access="public" output="false" returntype="TestBean">
        <cfscript>
            return(this);
        </cfscript>
    </cffunction>
   
</cfcomponent>

测试 CFM 代码

    <cfscript>
        arErrors= [];
    
        initiatedAsyncProcesses = [];
        initiatedAsyncProcesses.append(runAsync(function() {
            local.TestBean = new TestBean(); 
    
        }).error(
            function(error){arrayAppend(arErrors, error)}
            ));
    
        //Wait for errors
        sleep(100);
        writedump(arErrors);
    
    </cfscript>

Complete

产生错误

==> /opt/coldfusion2018/cfusion/logs/exception.log <==
"Error","pool-10-thread-12","10/03/23","10:21:07","","java.lang.NullPointerException"
java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
        at coldfusion.runtime.async.Future.get(Future.java:146)
        at coldfusion.runtime.async.CallableUDFMethod.call(CallableUDFMethod.java:90)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
异步 ColdFusion CFML

评论

0赞 Adrian J. Moreno 10/4/2023
所有文档仅显示从 CF 中的异步函数调用返回的简单结果(数字、字符串)。modern-cfml.ortusbooks.com/beyond-the-100/......
0赞 Adrian J. Moreno 10/4/2023
我看到你在 CFML Slack 中有一个解决方案:cfml.slack.com/archives/C06T99N9G/p1696324281487419

答: 暂无答案