Skip to content

Commit be91ad2

Browse files
committed
refactor : 로깅 및 예외 처리 강화
1 parent f0f055b commit be91ad2

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public Object lock(ProceedingJoinPoint joinPoint) throws Throwable {
3939
}
4040
}
4141

42+
if (problemId == null || userId == null) {
43+
throw new CodeReviewException(CodeReviewExceptionCode.REQUIRED_ARGS_NOT_FOUND);
44+
}
45+
4246
boolean locked = lockManager.tryLock(prefix, userId, problemId);
4347
if (!locked) {
4448
throw new CodeReviewException(CodeReviewExceptionCode.ALREADY_REVIEWING);

src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void submitCodeStream(SubmissionMessage msg) {
127127
exceptionNotificationHelper(e);
128128
} finally {
129129
emitterStore.remove(msg.emitterKey());
130-
lockManager.releaseLock("submission-", msg.userId(), msg.problemId());
130+
lockManager.releaseLock("submission", msg.userId(), msg.problemId());
131131
}
132132
}
133133

src/main/java/org/ezcode/codetest/domain/submission/exception/code/CodeReviewExceptionCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public enum CodeReviewExceptionCode implements ResponseCode {
1414
REVIEW_TIMEOUT(false, HttpStatus.GATEWAY_TIMEOUT, "AI 응답 시간이 초과되었습니다."),
1515
REVIEW_INVALID_FORMAT(false, HttpStatus.INTERNAL_SERVER_ERROR, "AI 리뷰 형식 검증에 실패했습니다."),
1616
ALREADY_REVIEWING(false, HttpStatus.CONFLICT, "이미 해당 코드에 대한 리뷰가 진행 중입니다."),
17+
REQUIRED_ARGS_NOT_FOUND(false, HttpStatus.BAD_REQUEST, "필수 인수를 메서드 시그니처에서 찾을 수 없습니다."),
1718
;
1819

1920
private final boolean success;

src/main/java/org/ezcode/codetest/infrastructure/scheduler/WeeklyTokenResetScheduler.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import org.springframework.scheduling.support.CronTrigger;
1515

1616
import jakarta.annotation.PostConstruct;
17+
import lombok.extern.slf4j.Slf4j;
1718

19+
@Slf4j
1820
@Configuration
1921
public class WeeklyTokenResetScheduler {
2022

@@ -37,12 +39,18 @@ public void schedule() {
3739
);
3840

3941
scheduler.schedule(() -> {
40-
LocalDate lastMonday = LocalDate.now(ZoneId.of("Asia/Seoul"))
41-
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
42-
LocalDateTime startDateTime = lastMonday.atStartOfDay();
43-
LocalDateTime endDateTime = lastMonday.plusDays(7).atStartOfDay();
44-
45-
userService.resetAllUsersTokensWeekly(startDateTime, endDateTime);
42+
try {
43+
log.info("주간 토큰 리셋을 시작합니다.");
44+
LocalDate lastMonday = LocalDate.now(ZoneId.of("Asia/Seoul"))
45+
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
46+
LocalDateTime startDateTime = lastMonday.atStartOfDay();
47+
LocalDateTime endDateTime = lastMonday.plusDays(7).atStartOfDay();
48+
49+
userService.resetAllUsersTokensWeekly(startDateTime, endDateTime);
50+
log.info("주간 토큰 리셋을 성공적으로 완료했습니다.");
51+
} catch (Exception e) {
52+
log.error("주간 토큰 리셋에 실패했습니다.", e);
53+
}
4654
}, trigger);
4755
}
4856
}

0 commit comments

Comments
 (0)