-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
ScriptEngine causes NullPointerException with multi-threads #3731
Comments
@shirosaki would it be possible for you to try out whether is still happens in 9.0.5.0 ... thanks! |
@kares I've tried 9.0.5.0. Different exception I was able to workaround the issue by using a global lock for JRuby initialization.
|
Could be some race when initializing the JRuby instance for ScriptingContainer. Is it sufficient to run the wro4j test suite to see this issue? If not, what's the easiest way for us to reproduce the bug? |
I can reproduce the bug by the following code. $ javac TestJRubyEmbedThread.java
$ java -classpath .:/path/to/jruby-complete-9.0.5.0.jar TestJRubyEmbedThread TestJRubyEmbedThread.java: import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
class TestJRubyEmbedThread extends Thread {
public TestJRubyEmbedThread() {
}
public void run() {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jruby");
try {
engine.eval("require 'webrick'");
} catch (ScriptException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
System.setProperty("org.jruby.embed.compat.version", "JRuby1.9");
for (int i = 0; i < 20; i++) {
new TestJRubyEmbedThread().start();
}
}
} |
After adding In documents, default: So I think JRuby 9.0.5.0 behavior looks like expected. |
Enforce in the node a jruby property that ensures jruby context to be thread-safe See jruby/jruby#3731
Enforce in the node a jruby property that ensures jruby context to be thread-safe See jruby/jruby#3731 (cherry picked from commit 84bce4b)
Environment
Expected Behavior
Multiple embed JRuby engines execute eval scripts normally with multi-threaded environments.
Actual Behavior
Multiple embed JRuby engines cause NullPointerException while executing eval scripts with multi-threaded environments.
Error log is here.
wro4j/wro4j#1007
This NullPointerException doesn't occur with JRuby 1.7.14.
The text was updated successfully, but these errors were encountered: