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

Benjamin Glatzeder commented on LANG-1719:
------------------------------------------

I found the last commit in the commons-lang project where
{code:java}
RandomStringUtils.random(12,"abcdefghijklmnopqrstuvwxyz0123456789"){code}
outputs random strings.

Detailed steps:
 * git clone [https://github.com/apache/commons-lang.git]
 * build snapshots with command mvn -Dcheckstyle.skip
 * add snapshot to Android project and check if strings are random
 * git checkout older commits, build, check for randomness, repeat

Last commit id with random strings: 5d51fc2878f0a2a8db47b7d0e1f0d534a7f79f2c
{code:java}
commit 5d51fc2878f0a2a8db47b7d0e1f0d534a7f79f2c (HEAD)
Author: Gary Gregory <garydgreg...@gmail.com>
Date:   Sun Apr 18 18:48:04 2021 -0400    Typo. {code}
First commit id with random strings that are equal: 
2978cb6cf05379fd42374eb5a235be84e021f247
{code:java}
commit 2978cb6cf05379fd42374eb5a235be84e021f247 (HEAD)
Author: Gary Gregory <garydgreg...@gmail.com>
Date:   Sun Apr 18 19:21:44 2021 -0400    DMI: Random object created and used 
only once
    (DMI_RANDOM_USED_ONLY_ONCE); Better multi-threaded behavior.    Thank you 
SpotBugs.
    Sort methods. {code}
Here are the changes between the two commits: 
[https://github.com/apache/commons-lang/commit/2978cb6cf05379fd42374eb5a235be84e021f247]

or copy the following command in git bash:
{code:java}
git diff 2978cb6cf05379fd42374eb5a235be84e021f247 
5d51fc2878f0a2a8db47b7d0e1f0d534a7f79f2c
 {code}

> RandomStringUtils.random outputs strings that are equal over and over
> ---------------------------------------------------------------------
>
>                 Key: LANG-1719
>                 URL: https://issues.apache.org/jira/browse/LANG-1719
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.13.0
>         Environment: Samsung Smartphone
> Product name: Galaxy A53 5G
> Model name: SM-A536B/DS
> Software info:
> One UI version 5.1
> Android version 13
>            Reporter: Benjamin Glatzeder
>            Priority: Major
>             Fix For: 3.12.0
>
>
> The following line of code outputs equal strings over and over:
> {code:java}
> RandomStringUtils.random(12,"abcdefghijklmnopqrstuvwxyz0123456789") {code}
> Steps to reproduce:
> 1) Create a new Android project in Android Studio
> 2) Add the following dependency to your gradle file
> {code:bash}
> implementation("org.apache.commons:commons-lang3:3.13.0") {code}
> 3) Use the following code in your MainActivity:
> {code:java}
> package test.randomstringutils
> import android.os.Bundle
> import android.util.Log
> import androidx.activity.ComponentActivity
> import org.apache.commons.lang3.RandomStringUtils
> class MainActivity : ComponentActivity() {
>     override fun onCreate(savedInstanceState : Bundle?) {
>         super.onCreate(savedInstanceState)
>         val randomString = 
> RandomStringUtils.random(12,"abcdefghijklmnopqrstuvwxyz0123456789")
>         Log.d(TAG, randomString)
>     }
>     companion object {
>         private const val TAG = "TAG"
>     }
> }
> {code}
> 4) Run project and note the string in Logcat
> 5) Run project again and compare the new random string in Logcat
> One will note that the strings are equal. The expected result should be that 
> the strings are not equal. Here's an example output:
> {code:java}
> 09:33:10.154 TAG                  tes...tringutils  D  m9mcx5ywuxdc
> 09:33:28.561 TAG                  tes...tringutils  D  m9mcx5ywuxdc
> {code}
> Using the previous commons-lang3 version in the project resolves the issue. 
> Here are the steps to reproduce:
> 1) Replace
> {code:bash}
> implementation("org.apache.commons:commons-lang3:3.13.0") {code}
> with
> {code:bash}
> implementation("org.apache.commons:commons-lang3:3.12.0") {code}
> 2) Click on "Sync now"
> 3) Run project and note the string in Logcat
> 4) Run project again and compare the new random string in Logcat
> One will note that the strings are not equal. This is the expected result. 
> Here's an example output:
> {code:java}
> 09:40:50.268 TAG                  tes...tringutils  D  1tjkvkta6ibi
> 09:40:55.324 TAG                  tes...tringutils  D  02nfvrf9pfgl{code}
>  
> I was able to consistently reproduce this issue using a Samsung Galaxy A53 5G 
> smartphone as well as on an Android Virtual Device (AVD). To the best of my 
> knowledge the smartphone runs on an ARM processor and the AVD has an emulated 
> ARM processor.
> I was *not* able to reproduce this issue when I created a Kotlin project in 
> IntelliJ with similar lines of code which was running on my Windows machine 
> with an x64 processor.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to