Skip to content

Commit

Permalink
Merge pull request #176 from Team-HMH/fix/#174-signup-npe
Browse files Browse the repository at this point in the history
fix - Optional ์•ˆ์— null์ด ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•˜์—ฌ NPE ๋ฐฉ์ง€
  • Loading branch information
kseysh authored Jul 15, 2024
2 parents a489c9a + 31ec77e commit e552391
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class ChallengeFacade {
@Transactional
public Challenge addChallenge(Long userId, ChallengeRequest challengeRequest, String os) {
User user = userService.findByIdOrThrowException(userId);
Optional<Long> previousChallengeId = Optional.of(user.getCurrentChallengeId());

Optional<Long> previousChallengeId = Optional.ofNullable(user.getCurrentChallengeId());

Challenge challenge = challengeService.save(challengeRequest.toEntity(userId));
user.changeCurrentChallengeId(challenge.getId());
Expand Down

0 comments on commit e552391

Please sign in to comment.