Use .setStatus in ResponseStatusExceptionResolver

Before this change ResponseStatusExceptionResolver always used
.sendError despite the javadoc on @ResponseStatus#code. This was
perhaps justifiable from a HandlerExceptionResolver. Nevertheless
.setStatus should be more REST API friendly while still marking
the response as an error.

Issue: SPR-11193
This commit is contained in:
Rossen Stoyanchev 2015-06-17 17:16:52 -04:00
parent 8d7812b1b6
commit 0ef8af4798
1 changed files with 1 additions and 1 deletions

View File

@ -101,7 +101,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
reason = this.messageSource.getMessage(reason, null, reason, LocaleContextHolder.getLocale());
}
if (!StringUtils.hasLength(reason)) {
response.sendError(statusCode);
response.setStatus(statusCode);
}
else {
response.sendError(statusCode, reason);