Skip to content

Commit

Permalink
fix: Slack 알림 전송 비동기 처리 시 HttpServletRequest의 생명주기가 먼저 종료되어 발생하던 에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeuk520 committed Sep 29, 2024
1 parent 4367ecd commit 4b78421
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ku.covigator.dto.response.ErrorResponse;
import com.ku.covigator.exception.CovigatorException;
import com.ku.covigator.support.slack.RequestInfo;
import com.ku.covigator.support.slack.SlackAlarmGenerator;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -80,7 +81,8 @@ public ResponseEntity<ErrorResponse> handleCovigatorException(CovigatorException

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleInternalException(Exception e, HttpServletRequest request) {
slackAlarmGenerator.sendSlackAlertErrorLog(e, request);
RequestInfo requestInfo = RequestInfo.from(request);
slackAlarmGenerator.sendSlackAlertErrorLog(e, requestInfo);
return ResponseEntity.internalServerError()
.body(new ErrorResponse(9999, "서버 복구중입니다. 잠시만 기다려주세요."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public class SlackAlarmGenerator {
private final Slack slack = Slack.getInstance();

@Async
public void sendSlackAlertErrorLog(Exception e, HttpServletRequest request) {

RequestInfo requestInfo = RequestInfo.from(request);
public void sendSlackAlertErrorLog(Exception e, RequestInfo requestInfo) {

try {
slack.send(slackProperties.getUrl(), payload(p -> p
Expand Down

0 comments on commit 4b78421

Please sign in to comment.