From 31ec77ebea9b3f5a8daa16a08c24accde0ecc8c5 Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 15 Jul 2024 22:45:54 +0900 Subject: [PATCH] =?UTF-8?q?fix=20-=20#174=20Optional=20=EC=95=88=EC=97=90?= =?UTF-8?q?=20null=EC=9D=B4=20=EB=93=A4=EC=96=B4=EA=B0=88=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=BD=94=EB=93=9C=EB=A5=BC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=98=EC=97=AC=20NPE=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/challenge/service/ChallengeFacade.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeFacade.java b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeFacade.java index f49bbbc7..a8e984e6 100644 --- a/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeFacade.java +++ b/src/main/java/sopt/org/hmh/domain/challenge/service/ChallengeFacade.java @@ -33,7 +33,8 @@ public class ChallengeFacade { @Transactional public Challenge addChallenge(Long userId, ChallengeRequest challengeRequest, String os) { User user = userService.findByIdOrThrowException(userId); - Optional previousChallengeId = Optional.of(user.getCurrentChallengeId()); + + Optional previousChallengeId = Optional.ofNullable(user.getCurrentChallengeId()); Challenge challenge = challengeService.save(challengeRequest.toEntity(userId)); user.changeCurrentChallengeId(challenge.getId());