From 0ef8af4798222eccfa69d3e3a0c339b170e6d072 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 17 Jun 2015 17:16:52 -0400 Subject: [PATCH] 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 --- .../servlet/mvc/annotation/ResponseStatusExceptionResolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolver.java index 674c03942f..d854fc4288 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolver.java @@ -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);