Skip to content

Commit 1ccb43f

Browse files
committed
feat: commons-lang 적용
1 parent 68f73b4 commit 1ccb43f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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

6366
tasks.named('test') {
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
package com.oronaminc.join.room.util;
22

3-
import java.util.Random;
4-
53
import lombok.AccessLevel;
64
import lombok.NoArgsConstructor;
5+
import org.apache.commons.lang3.RandomStringUtils;
76

87
@NoArgsConstructor(access = AccessLevel.PRIVATE)
98
public 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
}

0 commit comments

Comments
 (0)