File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
src/main/java/com/f_lab/la_planete/service Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public class OrderService {
29
29
private final FoodRepository foodRepository ;
30
30
private final PaymentRepository paymentRepository ;
31
31
32
- @ Transactional ( rollbackFor = IllegalStateException . class )
32
+ @ Transactional
33
33
public OrderCreateResponseDTO createFoodOrder (OrderCreateRequestDTO request ) {
34
34
35
35
// 음식을 조회 후 요청한 수 만큼 빼기
@@ -53,16 +53,10 @@ public OrderCreateResponseDTO createFoodOrder(OrderCreateRequestDTO request) {
53
53
54
54
private Food findFoodWithLock (Long foodId ) {
55
55
try {
56
- Food food = foodRepository .findFoodByFoodIdWithPessimisticLock (foodId );
57
- Thread .sleep (5000 );
58
- return food ;
56
+ return foodRepository .findFoodByFoodIdWithPessimisticLock (foodId );
59
57
} catch (PessimisticLockException | PessimisticLockingFailureException e ) {
60
58
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 ("오류 다시 시도해 주시길 바랍니다." );
66
60
}
67
61
}
68
62
}
You can’t perform that action at this time.
0 commit comments