You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Will Xiao (Jira)" <ji...@apache.org> on 2024/01/21 16:34:00 UTC

[jira] [Commented] (HDDS-10151) Random object created and used only once

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

Will Xiao commented on HDDS-10151:
----------------------------------

Thanks for review. [~adoroszlai]  
 * RandomUtils cannot directly set a seed.
In the below test classes (TestDeletedBlockLog.java, TestLeaderChoosePolicy.java, TestDeletedBlocksTxnShell.java)
We don't see much benefit to set a seed, so Random is replaced by RandomUtils
 * skipped TestBlockOutputStreamCorrectness in the current PR because it is using the same seed for both instances of Random, we may need another solution.
 * The test class TestMultipartObjectGet.java also doesn't really need to be secure so the SecureRandom is replaced by RandomUtils

> Random object created and used only once
> ----------------------------------------
>
>                 Key: HDDS-10151
>                 URL: https://issues.apache.org/jira/browse/HDDS-10151
>             Project: Apache Ozone
>          Issue Type: Sub-task
>          Components: test
>            Reporter: Attila Doroszlai
>            Assignee: Will Xiao
>            Priority: Minor
>              Labels: GoodForNewContributors, pull-request-available
>             Fix For: 1.5.0
>
>         Attachments: HDDS-10151.txt
>
>
> Replace single-use {{Random}} objects by {{RandomUtils}} or similar.
> Example:
> {code}
> -      int index = new Random().nextInt(dnInfos.size());
> +      int index = RandomUtils.nextInt(0, dnInfos.size());
> {code}
> See attached file for list of items to fix.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org