Ensure response is committed after ErrorPageFilter
Otherwise Tomcat will go ahead and uncommit it and handle it again in the ErrorReportValve (duh!) Fixes gh-684
This commit is contained in:
parent
d613cc795e
commit
0d44e6e0d2
|
|
@ -91,6 +91,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
|
|||
|
||||
private void doFilter(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
ErrorWrapperResponse wrapped = new ErrorWrapperResponse(response);
|
||||
try {
|
||||
chain.doFilter(request, wrapped);
|
||||
|
|
@ -102,6 +103,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
|
|||
catch (Throwable ex) {
|
||||
handleException(request, response, wrapped, ex);
|
||||
}
|
||||
response.flushBuffer();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
|
|||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link ErrorPageFilter}.
|
||||
|
|
@ -76,6 +77,7 @@ public class ErrorPageFilterTests {
|
|||
equalTo((Object) 400));
|
||||
assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE),
|
||||
equalTo((Object) "BAD"));
|
||||
assertTrue(this.response.isCommitted());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -96,6 +98,7 @@ public class ErrorPageFilterTests {
|
|||
equalTo((Object) 400));
|
||||
assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE),
|
||||
equalTo((Object) "BAD"));
|
||||
assertTrue(this.response.isCommitted());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -118,6 +121,7 @@ public class ErrorPageFilterTests {
|
|||
equalTo((Object) "BAD"));
|
||||
assertThat(this.request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE),
|
||||
equalTo((Object) RuntimeException.class.getName()));
|
||||
assertTrue(this.response.isCommitted());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue