Skip to content

Commit

Permalink
Merge pull request #112 from prgrms-be-devcourse/feature/#110
Browse files Browse the repository at this point in the history
[#110] lock 타임 아웃 시간 변경 및 예외 처리
  • Loading branch information
Hchanghyeon committed Sep 22, 2023
2 parents 2289918 + 21594b1 commit e50f6ab
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ public ReservationIdResponse createReservation(ReservationCreateRequest reservat
String key = REDISSON_LOCK_PREFIX + reservationCreateRequest.getScheduleId();
RLock lock = redissonClient.getLock(key);

boolean isLocked = false;
boolean isLocked;
ReservationIdResponse reservationIdResponse = null;

try {
isLocked = lock.tryLock(20, 1, TimeUnit.SECONDS);
isLocked = lock.tryLock(30, 1, TimeUnit.SECONDS);

if (!isLocked) {
throw new CommonException(COMMON_LOCK_ACQUISITION_FAILED, reservationCreateRequest);
throw new CommonException(COMMON_LOCK_ACQUISITION_FAILED, reservationCreateRequest.toString());
}

reservationIdResponse = reservationService.createReservation(reservationCreateRequest);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
if (isLocked) {
try {
lock.unlock();
} catch (IllegalMonitorStateException e) {
log.info("Redisson Lock Already UnLock");
}
}

Expand Down

0 comments on commit e50f6ab

Please sign in to comment.