diff --git a/src/main/java/com/example/solidconnection/cache/ThunderingHerdCachingAspect.java b/src/main/java/com/example/solidconnection/cache/ThunderingHerdCachingAspect.java index 6f0abc7f2..22652b1c1 100644 --- a/src/main/java/com/example/solidconnection/cache/ThunderingHerdCachingAspect.java +++ b/src/main/java/com/example/solidconnection/cache/ThunderingHerdCachingAspect.java @@ -7,6 +7,7 @@ import com.example.solidconnection.cache.annotation.ThunderingHerdCaching; import com.example.solidconnection.cache.manager.CacheManager; +import com.example.solidconnection.common.exception.CustomException; import com.example.solidconnection.util.RedisUtils; import java.time.Duration; import java.util.UUID; @@ -114,6 +115,8 @@ private Object executeWithLock(String lockKey, Callable onLockAcquired, } else { return onLockFailed.call(); } + } catch (CustomException e) { + throw e; } catch (Exception e) { throw new RuntimeException("Error during executeWithLock", e); } finally { @@ -150,6 +153,8 @@ private Object waitForCacheToUpdate(ProceedingJoinPoint joinPoint, String key) { private Object proceedJoinPoint(ProceedingJoinPoint joinPoint) { try { return joinPoint.proceed(); + } catch (CustomException e) { + throw e; } catch (Throwable e) { throw new RuntimeException("Error during proceedJoinPoint", e); } diff --git a/src/test/java/com/example/solidconnection/university/service/UnivApplyInfoQueryServiceTest.java b/src/test/java/com/example/solidconnection/university/service/UnivApplyInfoQueryServiceTest.java index f39762ba8..c914aab65 100644 --- a/src/test/java/com/example/solidconnection/university/service/UnivApplyInfoQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/university/service/UnivApplyInfoQueryServiceTest.java @@ -83,10 +83,8 @@ class 대학_지원_정보_상세_조회 { Long invalidUnivApplyInfoId = 9999L; // when & then - assertThatExceptionOfType(RuntimeException.class) + assertThatExceptionOfType(CustomException.class) .isThrownBy(() -> univApplyInfoQueryService.getUnivApplyInfoDetail(invalidUnivApplyInfoId)) - .havingRootCause() - .isInstanceOf(CustomException.class) .withMessage(UNIV_APPLY_INFO_NOT_FOUND.getMessage()); } }