From dae1a9866fafeb366997c2bdd3e7272eaf42b23c Mon Sep 17 00:00:00 2001 From: "aj4941@naver.com" Date: Mon, 25 Nov 2024 14:38:14 +0900 Subject: [PATCH] =?UTF-8?q?:pencil2:=20[FIX]=20Redis=20=EB=B6=84=EC=82=B0?= =?UTF-8?q?=EB=9D=BD=20=EC=BD=94=EB=93=9C=20=EC=9D=BC=EB=B6=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swm_nm/morandi/aop/lock/MemberLockAspect.java | 14 +++++--------- .../global/exception/errorcode/LockErrorCode.java | 5 ++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/swm_nm/morandi/aop/lock/MemberLockAspect.java b/src/main/java/swm_nm/morandi/aop/lock/MemberLockAspect.java index df726751..33da3f27 100644 --- a/src/main/java/swm_nm/morandi/aop/lock/MemberLockAspect.java +++ b/src/main/java/swm_nm/morandi/aop/lock/MemberLockAspect.java @@ -15,6 +15,7 @@ import swm_nm.morandi.global.utils.SecurityUtils; import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; @Aspect @Component @@ -23,8 +24,6 @@ public class MemberLockAspect { private final RedissonClient redissonClient; - - private final StringRedisTemplate redisTemplate; private final String MEMBER_LOCK_KEY = "memberLock"; @Pointcut("@annotation(swm_nm.morandi.aop.annotation.MemberLock)") public void memberLockPointcut() { @@ -42,15 +41,12 @@ public Object MEMBERLock(ProceedingJoinPoint joinPoint) throws Throwable { throw new MorandiException(LockErrorCode.MEMBER_LOCKED); } return joinPoint.proceed(); + } catch (InterruptedException e) { + throw new MorandiException(LockErrorCode.INTERRUPT_ERROR); } finally { if (locked) { - unlock(memberLockKey); + lock.unlock(); } } } - private void unlock(String key) { - redisTemplate.delete(key); - } - -} - +} \ No newline at end of file diff --git a/src/main/java/swm_nm/morandi/global/exception/errorcode/LockErrorCode.java b/src/main/java/swm_nm/morandi/global/exception/errorcode/LockErrorCode.java index a0077b69..0c72d405 100644 --- a/src/main/java/swm_nm/morandi/global/exception/errorcode/LockErrorCode.java +++ b/src/main/java/swm_nm/morandi/global/exception/errorcode/LockErrorCode.java @@ -9,10 +9,9 @@ @RequiredArgsConstructor @Getter public enum LockErrorCode implements ErrorCode { - MEMBER_LOCKED(HttpStatus.CONFLICT, "한 번에 여러 번의 요청을 받을 수 없습니다. 잠시만 기다려주세요."); + MEMBER_LOCKED(HttpStatus.CONFLICT, "한 번에 여러 번의 요청을 받을 수 없습니다. 잠시만 기다려주세요."), + INTERRUPT_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "인터럽트 예외가 발생했습니다."); private final HttpStatus httpStatus; private final String message; - - } \ No newline at end of file