Author: kkolinko Date: Wed Jun 11 22:55:01 2014 New Revision: 1602046 URL: http://svn.apache.org/r1602046 Log: https://issues.apache.org/bugzilla/show_bug.cgi?id=56581 Add test case for bug 56581. It tests exception handling for committed responses.
Added: tomcat/trunk/test/webapp/bug5nnnn/bug56581.jsp (with props) Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java?rev=1602046&r1=1602045&r2=1602046&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java (original) +++ tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java Wed Jun 11 22:55:01 2014 @@ -37,6 +37,7 @@ import static org.junit.Assert.assertTru import org.junit.Assert; import org.junit.Test; +import org.apache.catalina.LifecycleException; import org.apache.catalina.WebResourceRoot; import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Tomcat; @@ -317,4 +318,32 @@ public class TestGenerator extends Tomca } } + + @Test + public void testBug56581() throws LifecycleException { + Tomcat tomcat = getTomcatInstance(); + + File appDir = + new File("test/webapp"); + // app dir is relative to server home + tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); + + tomcat.start(); + + ByteChunk res = new ByteChunk(); + try { + getUrl("http://localhost:" + getPort() + + "/test/bug5nnnn/bug56581.jsp", res, null); + Assert.fail("An IOException was expected."); + } catch (IOException expected) { + // ErrorReportValve in Tomcat 8.0.9+ flushes and aborts the + // connection when an unexpected error is encountered and response + // has already been committed. It results in an exception here: + // java.io.IOException: Premature EOF + } + + String result = res.toString(); + assertTrue(result.startsWith("0 Hello world!\n")); + assertTrue(result.endsWith("999 Hello world!\n")); + } } Added: tomcat/trunk/test/webapp/bug5nnnn/bug56581.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug56581.jsp?rev=1602046&view=auto ============================================================================== --- tomcat/trunk/test/webapp/bug5nnnn/bug56581.jsp (added) +++ tomcat/trunk/test/webapp/bug5nnnn/bug56581.jsp Wed Jun 11 22:55:01 2014 @@ -0,0 +1,27 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--%><%@page contentType="text/plain;charset=ISO-8859-1" +%><% for (int i=0; i<1000; i++) { + out.print(i); + out.print(" Hello world!\n"); +} +if (true) throw new RuntimeException("Oops. Testing exception handling."); +for (int i=0; i<1000; i++) { + out.print(i); + out.print(" Footer"); +} +%> \ No newline at end of file Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug56581.jsp ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org