You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by vi...@apache.org on 2014/09/02 15:46:45 UTC

svn commit: r1621998 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/jasper/servlet/ test/org/apache/jasper/runtime/ test/webapp-3.0/jsp/ webapps/docs/

Author: violetagg
Date: Tue Sep  2 13:46:45 2014
New Revision: 1621998

URL: http://svn.apache.org/r1621998
Log:
Merged revision 1621975 from tomcat/trunk:
According to JavaDoc javax.servlet.jsp.PageContext.include(String) and javax.servlet.jsp.PageContext.include(String, boolean) must throw IOException if I/O error occur during the operation.
When JSPServlet init parameter "development" is "false" then IOException is re-thrown, but when the parameter is "true", JasperException is thrown instead of IOException.
This change guarantees that IOException is always re-thrown.

Added:
    tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/   (with props)
    tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext1.jsp
    tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext2.jsp
Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
    tomcat/tc7.0.x/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1621975

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java?rev=1621998&r1=1621997&r2=1621998&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Tue Sep  2 13:46:45 2014
@@ -456,8 +456,8 @@ public class JspServletWrapper {
             }
             throw ex;
         } catch (IOException ex) {
-            if(options.getDevelopment()) {
-                throw handleJspException(ex);
+            if (options.getDevelopment()) {
+                throw new IOException(handleJspException(ex).getMessage(), ex);
             }
             throw ex;
         } catch (IllegalStateException ex) {

Modified: tomcat/tc7.0.x/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java?rev=1621998&r1=1621997&r2=1621998&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/jasper/runtime/TestPageContextImpl.java Tue Sep  2 13:46:45 2014
@@ -80,6 +80,38 @@ public class TestPageContextImpl extends
         Assert.assertTrue(result.contains("OK"));
     }
 
+    @Test
+    public void testIncludeThrowsIOException() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = new File("test/webapp-3.0");
+        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+        tomcat.start();
+
+        ByteChunk res = new ByteChunk();
+
+        int rc = getUrl("http://localhost:" + getPort() + "/test/jsp/pageContext1.jsp", res, null);
+
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+        String body = res.toString();
+        Assert.assertTrue(body.contains("OK"));
+        Assert.assertFalse(body.contains("FAILED"));
+
+        res = new ByteChunk();
+
+        rc = getUrl("http://localhost:" + getPort() + "/test/jsp/pageContext1.jsp?flush=true", res,
+                null);
+
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+        body = res.toString();
+        Assert.assertTrue(body.contains("Flush"));
+        Assert.assertTrue(body.contains("OK"));
+        Assert.assertFalse(body.contains("FAILED"));
+    }
+
     public static class Bug56010 extends HttpServlet {
 
         private static final long serialVersionUID = 1L;

Propchange: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/
------------------------------------------------------------------------------
    bugtraq:append = false

Propchange: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/
------------------------------------------------------------------------------
    bugtraq:label = Bugzilla ID (optional)

Propchange: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Tue Sep  2 13:46:45 2014
@@ -0,0 +1,2 @@
+(https?\://issues.apache.org/bugzilla/show_bug.cgi\?id=\d+|BZ\s?\d+)
+(\d+)

Propchange: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/
------------------------------------------------------------------------------
--- bugtraq:message (added)
+++ bugtraq:message Tue Sep  2 13:46:45 2014
@@ -0,0 +1 @@
+Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=%BUGID%

Propchange: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/
------------------------------------------------------------------------------
    bugtraq:url = https://issues.apache.org/bugzilla/show_bug.cgi?id=%BUGID%

Added: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext1.jsp
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext1.jsp?rev=1621998&view=auto
==============================================================================
--- tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext1.jsp (added)
+++ tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext1.jsp Tue Sep  2 13:46:45 2014
@@ -0,0 +1,39 @@
+<%--
+  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 import="java.io.IOException" contentType="text/plain"%>
+<%
+    boolean flush = Boolean.valueOf(request.getParameter("flush"));
+    if (pageContext != null) {
+        try {
+            if (flush) {
+                out.println("Flush");
+                pageContext.include("/jsp/pageContext2.jsp", true);
+            } else {
+                pageContext.include("/jsp/pageContext2.jsp");
+            }
+        } catch (IOException e) {
+            out.println("OK");
+            return;
+        } catch (Throwable t) {
+            out.println("FAILED. Expected IOException, received: " + t.getClass().getName());
+            return;
+        }
+        out.println("FAILED. Expected IOException.");
+    } else {
+        out.println("FAILED. Expected IOException.");
+    }
+%>
\ No newline at end of file

Added: tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext2.jsp
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext2.jsp?rev=1621998&view=auto
==============================================================================
--- tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext2.jsp (added)
+++ tomcat/tc7.0.x/trunk/test/webapp-3.0/jsp/pageContext2.jsp Tue Sep  2 13:46:45 2014
@@ -0,0 +1,18 @@
+<%--
+  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 import="java.io.IOException" contentType="text/plain"%>
+<% throw new IOException("Throws IOException."); %>
\ No newline at end of file

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1621998&r1=1621997&r2=1621998&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Sep  2 13:46:45 2014
@@ -124,6 +124,14 @@
         functional impact but the code was less efficient as a result of the
         error. Based on a patch by martinschaef. (markt)
       </fix>
+      <fix>
+        Ensure that the implementation of
+        <code>javax.servlet.jsp.PageContext.include(String)</code>
+        and
+        <code>javax.servlet.jsp.PageContext.include(String, boolean)</code>
+        will throw <code>IOException</code> when an I/O error occur during
+        the operation. (violetagg)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="WebSocket">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org