Skip to content

Commit 714618c

Browse files
committed
fix: Fixed OrderService
- removed rollback in @transactional - removed Thread.sleep in findFoodWithLock() method
1 parent 7811975 commit 714618c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/main/java/com/f_lab/la_planete/service/OrderService.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class OrderService {
2929
private final FoodRepository foodRepository;
3030
private final PaymentRepository paymentRepository;
3131

32-
@Transactional(rollbackFor = IllegalStateException.class)
32+
@Transactional
3333
public OrderCreateResponseDTO createFoodOrder(OrderCreateRequestDTO request) {
3434

3535
// 음식을 조회 후 요청한 수 만큼 빼기
@@ -53,16 +53,10 @@ public OrderCreateResponseDTO createFoodOrder(OrderCreateRequestDTO request) {
5353

5454
private Food findFoodWithLock(Long foodId) {
5555
try {
56-
Food food = foodRepository.findFoodByFoodIdWithPessimisticLock(foodId);
57-
Thread.sleep(5000);
58-
return food;
56+
return foodRepository.findFoodByFoodIdWithPessimisticLock(foodId);
5957
} catch(PessimisticLockException | PessimisticLockingFailureException e) {
6058
log.warn("Pessimistic lock failure on food ID: {}", foodId, e);
61-
62-
// Decide whether to retry, fallback, or fail
63-
throw new IllegalStateException("The food item is currently locked. Please try again later.");
64-
} catch (InterruptedException e) {
65-
throw new RuntimeException(e);
59+
throw new IllegalStateException("오류 다시 시도해 주시길 바랍니다.");
6660
}
6761
}
6862
}

0 commit comments

Comments
 (0)