Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-902

RandomStringUtils.random (count, letters=true, number=true) may not use numerics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1
    • 3.2
    • lang.*

    Description

      Either there is a bug in an implementation or misunderstanding in docs.

      RandomStringUtils.random (count, letters, numbers) is documented so that:

      letters if true, generated string will include alphabetic characters
      numbers if true, generated string will include numeric characters

      But apparently the current implementation supports only that generated string may include either only letters, only numbers or both.

      This is current implementation:

      if (letters && Character.isLetter(ch) || numbers && Character.isDigit(ch) || !letters && !numbers)

      So there may be situation when generated string is not containing numbers at all which is in contrary with what the docs say.

      Attachments

        Activity

          People

            Unassigned Unassigned
            andrzej.winnicki Andrzej Winnicki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: