Worklight:适配器内部的递归函数调用 - 挂起Studio

时间:2013-06-08 10:43:44

标签: javascript recursion ibm-mobilefirst

我在适配器中有以下简单功能,当我从应用程序调用它时,它会挂起WL Studio并提供递归异常。

适配器功能

function listSummaries3009Details(param){
       var obj = com.MQNotifier.SimplePTP();
       var result = obj.getListSummaries3009(param) ;
       WL.Logger.debug("inside adapter :" + result);

       var xmlDoc = new XML(result);
     return { result : xmlDoc }; 
}

例外:

Error for /apps/services/api/myApp/common/query; java.lang.StackOverflowError
Error for /apps/services/api/myApp/common/query
     com.worklight.server.integration.api.JSObjectConverter.scriptableToJSON(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.getRecursiveValue(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.createJSONObject(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.nativeObjectToJSON(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.scriptableToJSON(Unknown Source)
                                      com.worklight.server.integration.api.InvocationResult.toJSON(Unknown Source)
                                      com.worklight.gadgets.serving.handler.query.JSONFeedGenerator.generateFeed(Unknown Source)
                                      com.worklight.gadgets.serving.handler.BackendQueryHandler.getContent(Unknown Source)
                                      com.worklight.gadgets.serving.handler.BackendQueryHandler.doPost(Unknown Source)
                                      com.worklight.gadgets.serving.GadgetAPIServlet.doGetOrPost(Unknown Source)
                                      com.worklight.gadgets.serving.GadgetAPIServlet.lockedGetOrPost(Unknown Source)
                                      com.worklight.gadgets.serving.GadgetAPIServlet.doPost(Unknown Source)
                                      javax.servlet.http.HttpServlet.service(Unknown Source)
                                      javax.servlet.http.HttpServlet.service(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.FilterChainImpl.doFilter(Unknown Source)
                                      com.worklight.core.auth.impl.AuthenticationFilter$1.execute(Unknown Source)
                                      com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(Unknown Source)
                                      com.worklight.core.auth.impl.AuthenticationFilter.doFilter(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.FilterRegistration.doFilter(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.FilterChainImpl.doFilter(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(Unknown Source)
                                      javax.servlet.http.HttpServlet.service(Unknown Source)
                                      org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(Unknown Source)
                                      org.mortbay.jetty.servlet.ServletHolder.handle(Unknown Source)
                                      org.mortbay.jetty.servlet.ServletHandler.handle(Unknown Source)
                                      org.mortbay.jetty.servlet.SessionHandler.handle(Unknown Source)
                                      org.mortbay.jetty.handler.ContextHandler.handle(Unknown Source)
                                      org.mortbay.jetty.handler.HandlerWrapper.handle(Unknown Source)
                                      org.mortbay.jetty.Server.handle(Unknown Source)
                                      org.mortbay.jetty.HttpConnection.handleRequest(Unknown Source)
                                      org.mortbay.jetty.HttpConnection$RequestHandler.content(Unknown Source)
                                      org.mortbay.jetty.HttpParser.parseNext(Unknown Source)
                                      org.mortbay.jetty.HttpParser.parseAvailable(Unknown Source)
                                      org.mortbay.jetty.HttpConnection.handle(Unknown Source)
                                      org.mortbay.io.nio.SelectChannelEndPoint.run(Unknown Source)
                                      org.mortbay.thread.QueuedThreadPool$PoolThread.run(Unknown Source)

现在,如果我运行上面的适配器功能,如下所示,那么它可以正常工作。

function listSummaries3009Details(param){
       var obj = com.MQNotifier.SimplePTP();
       var result = obj.getListSummaries3009(param) ;
       WL.Logger.debug("inside adapter :" + result);

       var xmlDoc = new XML(result);
     return { result : result }; 
}

请建议如何摆脱这个?

由于

1 个答案:

答案 0 :(得分:1)

你无法阻止递归。这是您的代码中的错误。你应该在函数的开头有一些东西来终止它。