Serious incompatibility in Thread#join(limit)
---------------------------------------------

                 Key: JRUBY-1600
                 URL: http://jira.codehaus.org/browse/JRUBY-1600
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.x
         Environment: Ubunty Linux 7.10,
ruby 1.8.5 (2007-11-21 rev 4842) [i386-jruby1.1b1]

            Reporter: Vladimir Sizikov
         Attachments: thread.diff

Thread#join(limit) always returns the thread instance, but this contradicts the 
ruby-doc Thread spec:
"If the time limit expires, nil will be returned, otherwise thr is returned." 
Even more, the example from the ruby-doc spec does not work:

"The following example illustrates the limit parameter.

   y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
   puts "Waiting" until y.join(0.15)

produces:

   tick...
   Waiting
   tick...
   Waitingtick...

   tick...
"

In JRuby case, the example produces nothing, and exits immediately.

Also, this problem causes Rubinius spec test failure:

#>bin/mspec -t jruby spec/core/thread
.......F.....

1)
Thread#join returns nil if it is not finished when given a timeout FAILED
Expected #<Thread:0xd0220c run>
to equal nil:
/opt/work/rubinius/spec/mini_rspec.rb:215:in `=='
/opt/work/rubinius/./spec/core/thread/join_spec.rb:20:in `=='
/opt/work/rubinius/./spec/core/thread/join_spec.rb:18:in `it'
/opt/work/rubinius/spec/mini_rspec.rb:355:in `it'
/opt/work/rubinius/./spec/core/thread/join_spec.rb:16:in `it'
/opt/work/rubinius/./spec/core/thread/join_spec.rb:16:in `describe'
/opt/work/rubinius/spec/mini_rspec.rb:399:in `describe'
/opt/work/rubinius/./spec/core/thread/join_spec.rb:4:in `describe'
/opt/work/rubinius/./spec/core/thread/join_spec.rb:4:in `load'
last_mspec.rb:11:in `load'
last_mspec.rb:1:in `each'
last_mspec.rb:6:in `each'

Attached patch fixes the problem with the example, and with the test.


-- 
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

Reply via email to