I'm not sure if this is a bug or "by design", I have seen some references that it may be by design.
The problem is it makes debugging very hard in jruby when a thread just dies with no error messages
printed.
Description of problem...
The following code has a typo, I am printing #{name} instead of #{@name}
What happens in JRuby is the thread dies with no error printed out.
Under C Ruby an error is printed out alerting me to my typo.
Without the `Thread.abort_on_exception= true' JRuby also prints out an error and both rubys do the
same thing.
=== Code: thread_bug.rb ====
Thread.abort_on_exception= true
@name= "my name"
t= Thread.new do
puts "thread starting..."
puts "this is a name #{name}"
puts "...exiting thread"
end
puts "waiting for thread"
t.join
puts "Program exiting"
=== end code ===
> ruby thread_bug.rb
thread starting...
bug.rb:6: undefined local variable or method `name' for #<Object:0xb7cd299c @name="my name"> (NameError)
from bug.rb:4:in `initialize'
from bug.rb:4:in `new'
from bug.rb:4
>
> /opt/jruby/bin/jruby bug.rb
waiting for thread
thread starting...
Program exiting
>
I'm happy to file a bug report if this indeed is a bug.
Thanks
Jim
--
Jim Morris, http://blog.wolfman.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Thanks for the report.
This looks like a clear bug to me, since JRuby's and MRI's behaviors
are different.
Please file a JIRA issue for that:
http://jira.codehaus.org/browse/JRUBY
Thanks,
--Vladimir
http://jira.codehaus.org/browse/JRUBY-2695
(To be fixed shortly).
Thanks,
--Vladimir
The bug has been fixed and the fix will appear in JRuby 1.1.3, but you
could try out the current trunk for verification purposes. :)
Thanks,
--Vladimir