Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResponseAdvice 동작 문제 #2

Open
PCloud63514 opened this issue May 23, 2022 · 1 comment
Open

ResponseAdvice 동작 문제 #2

PCloud63514 opened this issue May 23, 2022 · 1 comment

Comments

@PCloud63514
Copy link
Contributor

Demo Api를 추가 후 반환 결과가 ResponseAdvice로 Handling이 잘 이루어 지는 지 확인하는 중에 정상동작하지 않는 부분을 발견하였습니다.

@ResponseStatus(code = HttpStatus.CREATED)
@GetMapping("demo")
public void demo() {

}

형태로 반환 값이 없는 상태에서 ResponseStatus를 작성하면 ResponseAdvice.beforeBodyWrite로 전달되지 않습니다.
반환 값이 존재할 경우 정상동작하는 것은 확인되었습니다.
void 형태로 반환하더라도 ResponseStatus를 적용할 수 있는 방법이 있을까요?

@PCloud63514
Copy link
Contributor Author

추가 사항이 있어서 남깁니다.

import javax.servlet.http.HttpServletResponse;
...
@ResponseStatus(code = HttpStatus.CREATED)
@GetMapping("demo")
public void demo(HttpServletResponse response) {

}

api 파라미터에 HttpServletResponse를 포함할 경우 ResponseAdvice로 전달되지 않는 동일한 문제를 확인했습니다.
HttpSession, HttpServletRequest는 정상적으로 동작하는 것을 확인했습니다.

ResponseAdvice에서 ServerHttpResponse를 사용 중인 것이 문제인건지 해당사항에 대해 확인된 내용이 있을까요?

우선 조치사항으로 CommonResult를 직접적으로 호출하여 반환하도록 설정해두었습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant