[ 
https://issues.apache.org/jira/browse/LANG-805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas BELOT updated LANG-805:
------------------------------

    Description: 
In commons-lang 2.6 line 250 :
{code}ch = chars[random.nextInt(gap) + start];{code}
This line of code takes a random int to fetch a char in the _chars_ array 
regardless of it's size.
(Besides _start_ is useless here)

Fixed version would be : 
{code}ch = chars[random.nextInt(gap)%chars.length];{code}

  was:
In commons-lang 2.6 line 250 :
{code}ch = chars[random.nextInt(gap) + start];{code}
This line of code takes a random int to fetch a char in the {code}char{code} 
array regardless of it's size.
(Besides {code}start{code} is useless here)

Fixed version would be : 
{code}ch = chars[random.nextInt(gap)%chars.length];{code}

    
> RandomStringUtils.random(count, 0, 0, false, false, universe, random) always 
> throws java.lang.ArrayIndexOutOfBoundsException
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LANG-805
>                 URL: https://issues.apache.org/jira/browse/LANG-805
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.5, 2.6
>            Reporter: Thomas BELOT
>            Priority: Blocker
>              Labels: patch
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> In commons-lang 2.6 line 250 :
> {code}ch = chars[random.nextInt(gap) + start];{code}
> This line of code takes a random int to fetch a char in the _chars_ array 
> regardless of it's size.
> (Besides _start_ is useless here)
> Fixed version would be : 
> {code}ch = chars[random.nextInt(gap)%chars.length];{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to