@@ -187,7 +187,10 @@ abstract class OnCommittedResponseWrapper extends HttpServletResponseWrapper {
|
||||
*/
|
||||
private void checkContentLength(long contentLengthToWrite) {
|
||||
contentWritten += contentLengthToWrite;
|
||||
if(contentLength > 0 && contentWritten >= contentLength) {
|
||||
boolean isBodyFullyWritten = contentLength > 0 && contentWritten >= contentLength;
|
||||
int bufferSize = getBufferSize();
|
||||
boolean requiresFlush = bufferSize > 0 && contentWritten >= bufferSize;
|
||||
if(isBodyFullyWritten || requiresFlush) {
|
||||
doOnResponseCommitted();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1059,4 +1059,14 @@ public class OnCommittedResponseWrapperTests {
|
||||
|
||||
assertThat(committed).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bufferSizePrintWriterWriteCommits() throws Exception {
|
||||
String expected = "1234567890";
|
||||
when(response.getBufferSize()).thenReturn(expected.length());
|
||||
|
||||
response.getWriter().write(expected);
|
||||
|
||||
assertThat(committed).isTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user