Use sendError in ResponseStatusExceptionResolver

Prior to this commit, the `ResponseStatusExceptionResolver` would use:
* `HttpServletResponse.sendError` if both a status and a reason are set
on the `@ResponseStatus` annotation
* `HttpServletResponse.setStatus` if only a status is set on the
`@ResponseStatus` annotation

This is actually a change of behavior, since this Resolver was using
`sendError` in all cases previously.

Because this change can create issues such as
https://github.com/spring-projects/spring-boot/issues/3623
this commit rollbacks those changes and clarifies the behavior on the
javadoc of the annotation itself.

Issue: SPR-11193, SPR-13226
This commit is contained in:
Brian Clozel
2015-07-30 15:02:16 +02:00
parent 1ff3af6da3
commit 80767ff6e9
3 changed files with 17 additions and 8 deletions

View File

@@ -57,6 +57,7 @@ public class ResponseStatusExceptionResolverTests {
assertNotNull("No ModelAndView returned", mav);
assertTrue("No Empty ModelAndView returned", mav.isEmpty());
assertEquals("Invalid status code", 400, response.getStatus());
assertTrue("Response has not been committed", response.isCommitted());
}
@Test
@@ -67,6 +68,7 @@ public class ResponseStatusExceptionResolverTests {
assertTrue("No Empty ModelAndView returned", mav.isEmpty());
assertEquals("Invalid status code", 410, response.getStatus());
assertEquals("Invalid status reason", "You suck!", response.getErrorMessage());
assertTrue("Response has not been committed", response.isCommitted());
}
@Test