Skip to content

Commit 9baf80f

Browse files
committed
Revert "fix(exception): Handle session invalidation gracefully"
This reverts commit 827995e. The session invalidation handling approach caused recursive exceptions. Rolling back to investigate alternative solutions.
1 parent 827995e commit 9baf80f

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

src/main/kotlin/com/back/koreaTravelGuide/common/exception/GlobalExceptionHandler.kt

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.back.koreaTravelGuide.common.exception
22

33
import com.back.koreaTravelGuide.common.ApiResponse
44
import jakarta.servlet.http.HttpServletRequest
5-
import jakarta.servlet.http.HttpServletResponse
65
import org.slf4j.LoggerFactory
76
import org.springframework.http.HttpStatus
87
import org.springframework.http.ResponseEntity
@@ -44,21 +43,7 @@ class GlobalExceptionHandler {
4443
}
4544

4645
@ExceptionHandler(IllegalStateException::class)
47-
fun handleIllegalState(
48-
ex: IllegalStateException,
49-
response: HttpServletResponse,
50-
): ResponseEntity<ApiResponse<Void>> {
51-
// Spring Session 무효화 예외는 별도 처리
52-
if (ex.message?.contains("Session was invalidated") == true) {
53-
logger.debug("Session invalidation during response (ignoring): {}", ex.message)
54-
// 응답이 이미 커밋되었을 수 있으므로 상태 코드만 설정
55-
if (!response.isCommitted) {
56-
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse("세션이 만료되었습니다"))
57-
}
58-
// 이미 커밋된 경우 null 반환 (Spring이 처리)
59-
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse("세션이 만료되었습니다"))
60-
}
61-
46+
fun handleIllegalState(ex: IllegalStateException): ResponseEntity<ApiResponse<Void>> {
6247
logger.warn("부적절한 상태: {}", ex.message)
6348
return ResponseEntity.status(HttpStatus.CONFLICT).body(ApiResponse(ex.message ?: "요청을 처리할 수 없는 상태입니다"))
6449
}
@@ -67,17 +52,7 @@ class GlobalExceptionHandler {
6752
fun handleGenericException(
6853
ex: Exception,
6954
request: HttpServletRequest,
70-
response: HttpServletResponse,
7155
): ResponseEntity<ApiResponse<Void>> {
72-
// Spring Session 무효화 예외가 다른 예외 처리 중 발생한 경우
73-
if (ex is IllegalStateException && ex.message?.contains("Session was invalidated") == true) {
74-
logger.debug("Session invalidation during exception handling (ignoring): {}", ex.message)
75-
if (!response.isCommitted) {
76-
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse("세션이 만료되었습니다"))
77-
}
78-
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse("세션이 만료되었습니다"))
79-
}
80-
8156
// Static resource 예외는 무시 (favicon.ico, CSS, JS 등)
8257
if (ex is org.springframework.web.servlet.resource.NoResourceFoundException) {
8358
logger.debug("Static resource not found: {} at {}", ex.message, request.requestURI)

0 commit comments

Comments
 (0)