diff --git a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java index de1828c8ca..8ce25e3e33 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java @@ -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(); } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java index a7cdb113a2..a7e389bb91 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java @@ -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