Skip to content

Commit

Permalink
conflict: 에러 상황 유발
Browse files Browse the repository at this point in the history
  • Loading branch information
devholic22 committed Oct 14, 2024
1 parent 5a4429f commit 545fa81
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.flab.eattofit.member.infrastructure.member;

import com.flab.eattofit.member.domain.member.NicknameGenerator;
import com.flab.eattofit.member.exception.exceptions.member.NicknameRandomAlgorithmException;
import org.springframework.stereotype.Component;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand All @@ -17,14 +15,12 @@ public class RandomNicknameGenerator implements NicknameGenerator {

@Override
public String generateNickname(final String originName) {
try {
SecureRandom finalSecureRandom = SecureRandom.getInstanceStrong();
String generated = IntStream.range(0, RANDOM_LENGTH)
.mapToObj(value -> String.valueOf(finalSecureRandom.nextInt(DIGIT)))
.collect(Collectors.joining());
return originName + generated;
} catch (NoSuchAlgorithmException exception) {
throw new NicknameRandomAlgorithmException();
}
Random random = new Random();

String generated = IntStream.range(0, RANDOM_LENGTH)
.mapToObj(value -> String.valueOf(random.nextInt(DIGIT)))
.collect(Collectors.joining());

return originName + generated;
}
}

0 comments on commit 545fa81

Please sign in to comment.