-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime exception on setting cpu and memory restrictions. #27
Comments
Hello There! Thank you for reporting this issue. Could you have a look at this test case? I tried to recreate what you are describing. Is the test set up correctly? If I run it, the test succeeds. |
All the test cases which have cpu or memory monitoring are failing. I have gone through the code and with below changes both test cases and my code is working. JsSanitizer.java Line number : 244 try(final BufferedReader reader = new BufferedReader(new InputStreamReader( |
That's very interesting! I don't see why specifying the encoding should cause any problems here, so I have added the parameter and released a new version 0.1.4 with this fix to Maven central. Does this solve your issue? |
Yes, fix is working for me now. Thanks for a quick turnaround. |
That's great! I will close this issue now. If it comes up again, please be free to reopen or submit a different issue! |
I am consuming this library in a servlet container and it is always throwing the below error on call.
java.lang.RuntimeException: javax.script.ScriptException: SyntaxError: empty range in char class in at line number 1
at delight.nashornsandbox.internal.JsSanitizer.assertScriptEngine(JsSanitizer.java:124)
at delight.nashornsandbox.internal.JsSanitizer.(JsSanitizer.java:114)
at delight.nashornsandbox.internal.NashornSandboxImpl.getSanitizer(NashornSandboxImpl.java:172)
at delight.nashornsandbox.internal.NashornSandboxImpl.eval(NashornSandboxImpl.java:117)
sandbox = NashornSandboxes.create();
sandbox.setMaxCPUTime(100);
sandbox.setMaxMemory(50 * 1024);
sandbox.allowNoBraces(false);
sandbox.setMaxPerparedStatements(30); // because preparing scripts for
// execution is expensive
sandbox.setExecutor(Executors.newSingleThreadExecutor());
in servlet doGet () {
sandbox.eval("function callMe() { return 42; };");
final Object _get = sandbox.get("callMe");
}
The text was updated successfully, but these errors were encountered: