2015-02-04 14:45 GMT+03:00 <ma...@apache.org>: > Author: markt > Date: Wed Feb 4 11:45:39 2015 > New Revision: 1657125 > > URL: http://svn.apache.org/r1657125 > Log: > Fix failing NIO2 unit test. > Response body may not be chunked so doing a line-by-line read will fail > unless the client is explicitly told to use the content length. > > Modified: > tomcat/trunk/test/org/apache/coyote/http11/TestInternalOutputBuffer.java > > Modified: > tomcat/trunk/test/org/apache/coyote/http11/TestInternalOutputBuffer.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http11/TestInternalOutputBuffer.java?rev=1657125&r1=1657124&r2=1657125&view=diff > ============================================================================== > --- tomcat/trunk/test/org/apache/coyote/http11/TestInternalOutputBuffer.java > (original) > +++ tomcat/trunk/test/org/apache/coyote/http11/TestInternalOutputBuffer.java > Wed Feb 4 11:45:39 2015 > @@ -41,6 +41,10 @@ public class TestInternalOutputBuffer ex > ExpectationClient client = new ExpectationClient(); > > client.setPort(tomcat.getConnector().getLocalPort()); > + // Expected content doesn't end with a CR-LF so if it isn't chunked > make > + // sure the content length is used as reading it line-by-line will > fail > + // since there is no "line". > + client.setUseContentLength(true); > > client.connect();
The change is OK but the explanation & comment is odd to me. I think the reason for this change is that now we are not waiting for end-of-stream on a connection that is in keep-alive state (wasting our time waiting for a timeout), but use the response content length to stop reading earlier. SimpleHttpClient.processBody(boolean) [[[ // not using content length, so just read it line by line String line = null; while ((line = readLine()) != null) { builder.append(line); } ]]] The readLine() loop in SimpleHttpClient.processBody() terminates when line = readLine() returns null. This happens on end-of-stream. Whether the last character in the stream is a LF / CR-LF / CR does not matter. By the way, BufferedReader.readLine() documentation says that the method returns "A String containing the contents of the line, not including any line-termination characters", thus reconstructing the response body by concatenating those lines as done by SimpleHttpClient will miss any [CR]-LFs. Recent Buildbot build are hanging and are killed after a timeout, before they start running this test. (No recent test results for this test exist at buildbot) Thus I do not see what the error is. Older runs are OK, http://ci.apache.org/projects/tomcat/tomcat9/logs/1656590/TEST-org.apache.coyote.http11.TestInternalOutputBuffer.NIO2.txt Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org