Hash#each_pair behavior with concurrent modification is inconsistent with 
1.8.7p174
-----------------------------------------------------------------------------------

                 Key: JRUBY-4277
                 URL: http://jira.codehaus.org/browse/JRUBY-4277
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules, Ruby 1.8.7
    Affects Versions: JRuby 1.4
         Environment: MRI 1.8.7p174 (compiled by hand on Ubuntu)
MRI 1.8.6p287 (system package on OS X 10.5)
JRuby 1.4.0 (from macports on OS X 10.5)
            Reporter: Rhett Sutphin
            Priority: Minor


Hash#each_pair behaves differently when you add new keys to the hash during 
iteration on JRuby 1.4.0 and MRI 1.8.7p174.  This gist contains a short script 
which illustrates the different behaviors:

http://gist.github.com/243048

JRuby 1.4.0's behavior is the same as Ruby 1.9.0, not 1.8.7.

I don't know how important this difference is -- the 1.8 line's behavior is 
inconsistent (it seems to be dependent on the iteration order of the pairs), so 
it would be tricky to be deliberately depending on it.  On the other hand, we 
did  run into it in production code: a colleague of mine noticed the problem 
when executing a method which recursively converted all the keys in a hash to 
symbols (in place).  On MRI 1.8.x, this method would complete, but not on JRuby 
1.4.0.  (It was trivial to convert this method to a form that would work in 
both places.)

I attempted to write a RubySpec for this, but since the 1.8 behavior doesn't 
seem deliberately designed, I wasn't sure how to go about it.  I will update 
this ticket if I make any progress.

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