GitHub user allquantor opened a pull request:
https://github.com/apache/commons-lang/pull/211
Fixed possible infinite loop in random of RandomStringUtils
Hi,
I faced that the `random` method can cause an infinite loop. It can be
caused if the **end** parameter is too low for generating either numbers (< 48)
or letters (<65). I added some exception tests to make the cases clear.
Basically, if we call the random function with for example `numbers = true &&
end < 48
`
the validation for `Character.isDigit(ch)` will fail and we increment
count `count++`.
Moreover:
- Removed the white spaces in RandomStringUtilsTest.java
- Added the terms (inclusive) (exclusive) to the Javadoc of the random
method to make it more clear.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/allquantor/commons-lang
bugfix/infinite-loop-random
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/211.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #211
----
commit 5779612199c76bd218223dc7da4446bf6760640d
Author: Ivan Morozov <[email protected]>
Date: 2016-11-15T10:49:11Z
1.) Fixed possible infinite loop that can be caused by generating either
digits or letters by calling with a to low end param. 2.) Added (inclusive) and
(exclusive) terms to javadoc of random method
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---