NPE when running block in adopted thread
----------------------------------------
Key: JRUBY-979
URL: http://jira.codehaus.org/browse/JRUBY-979
Project: JRuby
Issue Type: Bug
Environment: Windows XP / Sun JVM 1.6.0 / JRuby trunk (revision: 3714)
Reporter: Peter K Chan
Assignee: Thomas E Enebo
When running blocks in a foreign Java thread, the thread adoption sometimes
does not happen properly, resulting a NPE when running the block. This error is
present even when block.to_proc.
Initial symptom:
Exception in thread "CPU0" java.lang.NullPointerException
at org.jruby.runtime.Block.call(Block.java:174)
at org.jruby.RubyProc.call(RubyProc.java:173)
at org.jruby.RubyProc.call(RubyProc.java:148)
at org.jruby.javasupport.Java$1.invoke(Java.java:853)
at $Proxy0.run(Unknown Source)
at java.lang.Thread.run(Thread.java:595)
My debugging traced the NPE to this method in ThreadService.java, which returns
null:
public ThreadContext getCurrentContext() {
WeakReference wr = (WeakReference) localContext.get();
if (wr == null) {
wr = adoptCurrentThread();
} else if(wr.get() == null) {
wr = adoptCurrentThread();
}
return (ThreadContext)wr.get(); // Can still return null. Bug?
}
For details, see this discussion:
http://archive.jruby.codehaus.org/dev/000201c79ce3%245c593d50%246601a8c0%40pkcshuttle
Initial diagnosis from Charlie: "It looks as though the thread isn't getting
adopted early enough."
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email