File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
src/main/java/com/oronaminc/join/room/util Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ dependencies {
5858
5959 // bucket4j
6060 implementation ' com.bucket4j:bucket4j_jdk17-core:8.14.0'
61+
62+ // commons-lang3
63+ implementation ' org.apache.commons:commons-lang3:3.18.0'
6164}
6265
6366tasks. named(' test' ) {
Original file line number Diff line number Diff line change 11package com .oronaminc .join .room .util ;
22
3- import java .util .Random ;
4-
53import lombok .AccessLevel ;
64import lombok .NoArgsConstructor ;
5+ import org .apache .commons .lang3 .RandomStringUtils ;
76
87@ NoArgsConstructor (access = AccessLevel .PRIVATE )
98public class CodeGenerator {
9+
1010 private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
11- private static final Random random = new Random ();
1211
1312 public static String generateCode (int length ) {
14- StringBuilder sb = new StringBuilder (length );
15- for (int i = 0 ; i < length ; i ++) {
16- int idx = random .nextInt (CHAR_POOL .length ());
17- sb .append (CHAR_POOL .charAt (idx ));
18- }
19- return sb .toString ();
13+
14+ return RandomStringUtils .random (length , CHAR_POOL );
2015 }
2116}
You can’t perform that action at this time.
0 commit comments