Merge branch '1.1.x'

pull/1923/merge
Andy Wilkinson 10 years ago
commit 8635724521

@ -112,7 +112,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
handleErrorStatus(request, response, status, wrapped.getMessage()); handleErrorStatus(request, response, status, wrapped.getMessage());
response.flushBuffer(); response.flushBuffer();
} }
else if (!request.isAsyncStarted()) { else if (!request.isAsyncStarted() && !response.isCommitted()) {
response.flushBuffer(); response.flushBuffer();
} }
} }
@ -184,7 +184,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
+ request.getRequestURI() + " as the response has already been" + request.getRequestURI() + " as the response has already been"
+ " committed. As a result, the response may have the wrong status" + " committed. As a result, the response may have the wrong status"
+ " code. If your application is running on WebSphere Application" + " code. If your application is running on WebSphere Application"
+ " Server you may be able to resolve this problem by setting " + " Server you may be able to resolve this problem by setting"
+ " com.ibm.ws.webcontainer.invokeFlushAfterService to false"; + " com.ibm.ws.webcontainer.invokeFlushAfterService to false";
if (ex == null) { if (ex == null) {
logger.error(message); logger.error(message);

@ -40,6 +40,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/** /**
* Tests for {@link ErrorPageFilter}. * Tests for {@link ErrorPageFilter}.
@ -343,4 +347,16 @@ public class ErrorPageFilterTests {
assertTrue(this.response.isCommitted()); assertTrue(this.response.isCommitted());
} }
@Test
public void responseIsNotFlushedIfStatusIsLessThan400AndItHasAlreadyBeenCommitted()
throws Exception {
HttpServletResponse committedResponse = mock(HttpServletResponse.class);
given(committedResponse.isCommitted()).willReturn(true);
given(committedResponse.getStatus()).willReturn(200);
this.filter.doFilter(this.request, committedResponse, this.chain);
verify(committedResponse, times(0)).flushBuffer();
}
} }

Loading…
Cancel
Save