Handling ResponseStatusException Results in 502
維護者通常 1 天內回覆
@sapessi 已經在處理了。
開始於 2020年7月10日。
評估
這個 Issue 還沒有評估資料。
描述
- Framework version: 1.5 / 5.2.6-RELEASE
- Implementations: Spring
Scenario
I am throwing a ResponseStatusException to handle 404's, 500's, etc but no matter when I throw one I am getting the following response with a 502 from the call:
{
"message": "Gateway timeout"
}
This is an example of how I am creating the ResponseStatusException:
if(queryResults.getSize() == 0) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Unable To Find User for Email Address %s", email));
} else {
// Do something else
}
I am seeing the following in my logs so I know the exception is being thrown properly:
2020-05-04 21:20:04 f1ab9c4e-75ee-457f-b222-dedc69daf8f5 ERROR LambdaContainerHandler - Error while handling request
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.server.ResponseStatusException: 404 NOT_FOUND "Unable To Find User for Email Address [email protected]"
It doesn't seem to handle the ResponseStatusException being thrown. I added the following to my application config class:
/*
* optimization - avoids creating default exception resolvers; not required as the serverless container handles
* all exceptions
*
* By default, an ExceptionHandlerExceptionResolver is created which creates many dependent object, including
* an expensive ObjectMapper instance.
*
* To enable custom @ControllerAdvice classes remove this bean.
*/
@Bean
public HandlerExceptionResolver handlerExceptionResolver() {
return new HandlerExceptionResolver() {
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
return null;
}
};
}
Shouldn't the container handle the ResponseStatusException automatically?
Thanks,
Steve
Expected behavior
The proper response code and response returned
Actual behavior
Always retuning a 502 and Bad Gateway reponse
- 主要語言
- Java
- 星號
- 1.6k
- 分支
- 575
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 12
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
aws/serverless-java-container 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
aws/serverless-java-container#1729 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
aws/serverless-java-container#1715 ·
維護者通常 1 天內回覆
-
Support for API Gateway mTLS clientCert field可能已有人在做 @2748109647 於 10 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 48/100
aws/serverless-java-container#1726 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
aws/serverless-java-container#1579 · 3 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 42/100
aws/serverless-java-container#1568 · 1 則留言 ·
維護者通常 1 天內回覆
查看 aws/serverless-java-container 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
ls1intum/thesis-management#1473 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
LunaDeerMC/Dominion#301 · 1 則留言 ·
-
[FEATURE] Expose external refresh, node-level translog and warmer stats可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉untriaged
難度 2/5 1-3 小時 新手友好度 68/100
opensearch-project/opensearch-prometheus-exporter#680 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100