[
https://issues.apache.org/jira/browse/LANG-1719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17787691#comment-17787691
]
Gilles Sadowski commented on LANG-1719:
---------------------------------------
Maybe related: https://issuetracker.google.com/issues/234631055?pli=1
> 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)