You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure that it is issue of library itself (maybe issue of using). But issue description absolutely not clear ("null"), even after sources investigation.
I have using Rhino to call JS function from few files from few threads (any file from any thread). Structure is:
"globalScope": is Scriptable. Used as common scope. Created on initialization with
"scopesCache": is HashMap<String, Scriptable>. Used to store scriptable-per-file. Each Scriptable cached on first call (of function from file). Used as
java.lang.IllegalStateException: null
at org.mozilla.javascript.ScriptRuntime.storeScriptable(ScriptRuntime.java:4197) ~[runner.jar:2.7.0-SNAPSHOT]
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2426) ~[runner.jar:2.7.0-SNAPSHOT]
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2405) ~[runner.jar:2.7.0-SNAPSHOT]
at xxx ~[na:na]
at xxx ~[na:na]
at xxx callFunctionInGlobalScope(JavaScriptManager.java:170) ~[runner.jar:2.7.0-SNAPSHOT]
Repro is not 100%. If try to run it manually not reproduced at all. But on intensive using (js handled HTTP requests, js functions called each other from few scopesCache) it reproduced oftenly.
Hello
I am not sure neither about the exact reason of the error nor about your usage scenario, but I would recommend not to share scope object. Instead, you can cache compiled script or function instances and create new scope for each particular request. Scopes as far as I see are not intended to be shared in multi thread environments.
P S. You also may use mailing list to duplicate your question there.
Thank you. I have tried your advise. But in this case I see performance degradation (about 5-10 times), seems like because I need to call script.exec in each request.
Should I close this issue? java.lang.IllegalStateException: null still not clear and "Scopes as far as I see are not intended to be shared in multi thread environments" not described in documentation AFAIK.
Not sure that it is issue of library itself (maybe issue of using). But issue description absolutely not clear ("null"), even after sources investigation.
I have using Rhino to call JS function from few files from few threads (any file from any thread). Structure is:
"globalScope": is Scriptable. Used as common scope. Created on initialization with
"scopesCache": is
HashMap<String, Scriptable>
. Used to store scriptable-per-file. EachScriptable
cached on first call (of function from file). Used asObject calledFunction = oneFromScopesCache.get(funcName, oneFromScopesCache);
((Function) calledFunction).call(context, globalScope, thisScope, funcArgs);
In last line I catch:
As I see it related to
scratchScriptable
in contextNote:
Repro is not 100%. If try to run it manually not reproduced at all. But on intensive using (js handled HTTP requests, js functions called each other from few
scopesCache
) it reproduced oftenly.To put Scriptable into
scopesCache
used code:Scriptable scriptScope = context.newObject(globalScope);
scriptScope.setParentScope(globalScope);
script.exec(context, scriptScope);
scopesCache.put("xxx", scriptScope)
The text was updated successfully, but these errors were encountered: