I found a problem with setting the buffer size for the ServletResponse.
If I call 'response.setBufferSize(1,000,000);' and send about 20,000 characters, the response will be chunked even though it should not.
The response is sent in several chunks and contains the 'Transfer-Encoding: chunked' response header.
In my understanding in this case the response should be fully buffered on the server and then sent as a whole containing the Content-Length-header.
This causes a problem in my application because I want to use a larger buffer to be able to redirect to an error page if an error occurs during rendering the response.
I was able to reproduce this on Tomcat 7.0.39, 7.0.40, 7.0.42, 7.0.47. Tomcat 7.0.37 works fine and as expected.
This is easily reproducable by using a JSP as follows:
<%
response.setBufferSize(1000*1000);
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
response.getWriter().write("X");
}
response.getWriter().write("<br />");
}
%>

1. Usually the buffer size of a JSP page is configured via @page directive.
I suspect that response.setBufferSize() is a wrong API here and configures something else.
2. What is the size of the first chunk of that chunked response?

1. It is reproducable with a simple Servlet as well. In fact, I found this bug using a JSF application where the response was chunked, even though I set the context-param 'javax.faces.FACELETS_BUFFER_SIZE' to a high value (over 1MB). Myfaces calls response.setBufferSize with the correct value.
2. All chunks are 2,000 bytes (looks like this is some kind of default)
I have created and attached a simple project that you can use to see the problem. Just deploy the Servlet to Tomcat and run the test case. The test case shows the chunks in System.err.

This is ASF Bugzilla: the Apache Software Foundation bug system. In case
of problems with the functioning of ASF Bugzilla, please contact
bugzilla-admin@apache.org.
Please Note: this e-mail address is only for reporting problems
with ASF Bugzilla. Mail about any other subject will be silently
ignored.