Commit 0d44e6e0 authored by Dave Syer's avatar Dave Syer

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
parent d613cc79
...@@ -91,6 +91,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple ...@@ -91,6 +91,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
private void doFilter(HttpServletRequest request, HttpServletResponse response, private void doFilter(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
ErrorWrapperResponse wrapped = new ErrorWrapperResponse(response); ErrorWrapperResponse wrapped = new ErrorWrapperResponse(response);
try { try {
chain.doFilter(request, wrapped); chain.doFilter(request, wrapped);
...@@ -102,6 +103,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple ...@@ -102,6 +103,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
catch (Throwable ex) { catch (Throwable ex) {
handleException(request, response, wrapped, ex); handleException(request, response, wrapped, ex);
} }
response.flushBuffer();
} }
......
...@@ -34,6 +34,7 @@ import org.springframework.mock.web.MockHttpServletResponse; ...@@ -34,6 +34,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/** /**
* Tests for {@link ErrorPageFilter}. * Tests for {@link ErrorPageFilter}.
...@@ -76,6 +77,7 @@ public class ErrorPageFilterTests { ...@@ -76,6 +77,7 @@ public class ErrorPageFilterTests {
equalTo((Object) 400)); equalTo((Object) 400));
assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE), assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE),
equalTo((Object) "BAD")); equalTo((Object) "BAD"));
assertTrue(this.response.isCommitted());
} }
@Test @Test
...@@ -96,6 +98,7 @@ public class ErrorPageFilterTests { ...@@ -96,6 +98,7 @@ public class ErrorPageFilterTests {
equalTo((Object) 400)); equalTo((Object) 400));
assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE), assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE),
equalTo((Object) "BAD")); equalTo((Object) "BAD"));
assertTrue(this.response.isCommitted());
} }
@Test @Test
...@@ -118,6 +121,7 @@ public class ErrorPageFilterTests { ...@@ -118,6 +121,7 @@ public class ErrorPageFilterTests {
equalTo((Object) "BAD")); equalTo((Object) "BAD"));
assertThat(this.request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE), assertThat(this.request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE),
equalTo((Object) RuntimeException.class.getName())); equalTo((Object) RuntimeException.class.getName()));
assertTrue(this.response.isCommitted());
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment