Skip to content

Commit

Permalink
fix - #174 Optional 안에 null이 들어갈 수 있도록 코드를 변경하여 NPE 방지
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed Jul 15, 2024
1 parent a489c9a commit 31ec77e
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 31ec77e

Please sign in to comment.