You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Duncan Jones (JIRA)" <ji...@apache.org> on 2016/11/12 07:13:58 UTC

[jira] [Commented] (LANG-1284) RandomStringUtils' random method goes into an infinite loop

    [ https://issues.apache.org/jira/browse/LANG-1284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15659193#comment-15659193 ] 

Duncan Jones commented on LANG-1284:
------------------------------------

I'm not sure if this can be prevented with very inefficient scanning of the input array. Perhaps the best approach here is a warning in the Javadocs.

The Javadocs need a clean up anyway, I can't really understand the opening paragraphs:

{quote}
If start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, unless letters and numbers are both false, in which case, start and end are set to 0 and Integer.MAX_VALUE.

If set is not null, characters between start and end are chosen.{quote}

> RandomStringUtils' random method goes into an infinite loop
> -----------------------------------------------------------
>
>                 Key: LANG-1284
>                 URL: https://issues.apache.org/jira/browse/LANG-1284
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Arul Nedumaran
>
> The following code goes into an infinite loop.
> {code}
> RandomStringUtils.random(1, 0, 0, false, true, new char[]{ 'a' })
> {code}
> I know it doesn't make sense to pass letters=false and then a letter array, but a bug in the caller's code will make him fall into this trap.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)