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