Calling the attached method after 6 times returns nil
-----------------------------------------------------

                 Key: JRUBY-2041
                 URL: http://jira.codehaus.org/browse/JRUBY-2041
             Project: JRuby
          Issue Type: Bug
          Components: Interpreter
    Affects Versions: JRuby 1.1RC1
         Environment: Ubuntu Feisty Fawn
            Reporter: K Venkatasubramaniyan


Here is an issue that appears weird to me. Calling the following same method 
after 6 times results in returning nil value.

Here are the steps to reproduce the issue. Note: Please run this code under 
Rails script/console as it requires the ActiveSupport stuff.

    def do_masking_failing(account_num, account_mask_char, pattern)
      result = pattern.dup
      if account_num.size <= pattern.size
        i = 0
        j = 0
        pattern.each_char{|char|
            case char
            when 'X'
              result[i] = account_mask_char
            when '-'
              result[i] = '-'
              j -= 1
            when '#'
              result[i] = account_num[j]
            end
            i += 1
            j += 1
            break if j == account_num.size
        }
        result
      else
        account_num
      end      
    end

masking_stuff = [["111122224444", "XXXXXXXX####", "x"], ["112233445566", 
"#####XXX####", "x"], ["999933331111", "############", "x"]]
10.times { p masking_stuff.collect {|m| do_masking_failing(m[0], m[2], m[1] )  
}  }

The above stuff results in the following output.  Note that after the 6th time 
running the call, it starts returning nil. 

["xxxxxxxx4444", "11223xxx5566", "999933331111"]
["xxxxxxxx4444", "11223xxx5566", "999933331111"]
["xxxxxxxx4444", "11223xxx5566", "999933331111"]
["xxxxxxxx4444", "11223xxx5566", "999933331111"]
["xxxxxxxx4444", "11223xxx5566", "999933331111"]
["xxxxxxxx4444", "11223xxx5566", "999933331111"]
nil
nil
nil
nil



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