commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-808) RandomStringUtils inefficient init of start and end for letters and numbers; misleading Javadoc
Date Thu, 17 Oct 2013 07:16:47 GMT

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

Henri Yandell commented on LANG-808:
------------------------------------

Originally I'm sure I thought of it as a password generator, so ASCII was an assumption I
wasn't noticing. 

We should note this in the javadoc, see if we can clean any of it up and consider if there's
a possible refactoring of the API that would be more valuable.

> RandomStringUtils inefficient init of start and end for letters and numbers; misleading
Javadoc
> -----------------------------------------------------------------------------------------------
>
>                 Key: LANG-808
>                 URL: https://issues.apache.org/jira/browse/LANG-808
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.6, 3.1
>            Reporter: Sebb
>             Fix For: Patch Needed
>
>
> If either letters or numbers is true, RandomStringUtils(count, 0, 0, letters, numbers,
...) sets the default start index to space, intending to support the set of printable characters
(according to the Javadoc).
> However, the code later uses Character.isLetter and Character.isDigit, which exclude
space and some other printable characters.
> There is currently no direct support for generating printable characters; this would
probably require another flag.
> The current Javadoc is misleading, and the current code is inefficient because some characters
cannot currently be used.
> The lowest char which is either digit or letter is '0' (zero).
> The lowest char which is a letter is 'A' (upper case a).
> The Javadoc for the randomNumeric(int) method says:
> bq. Characters will be chosen from the set of numeric characters.
> This does not make clear that the numerics are restricted to the ASCII set (because of
the way start=end=0 is handled).
> Similarly for randomAlphabetic and randomAlphanumeric.
> Is it the intention that randomAlphabetic etc. be restricted to ASCII?



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message