Author: markt
Date: Wed Feb 25 11:23:00 2015
New Revision: 1662200
URL: http://svn.apache.org/r1662200
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=57626
Ensure that when processing a tag file within a Jar that the
JspComppilationContext always has the latest, opened Jar instance to work with.
Add a unit test for recompilation of a modified JSOP that depends on a tag file
packaged in a Jar.
Modified:
tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
tomcat/trunk/test/org/apache/jasper/TestJspCompilationContext.java
tomcat/trunk/test/webapp/WEB-INF/web.xml
Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=1662200&r1=1662199&r2=1662200&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java Wed Feb 25
11:23:00 2015
@@ -89,7 +89,7 @@ public class JspCompilationContext {
private final boolean isTagFile;
private boolean protoTypeMode;
private TagInfo tagInfo;
- private final Jar tagJar;
+ private Jar tagJar;
// jspURI _must_ be relative to the context
public JspCompilationContext(String jspUri, Options options,
@@ -310,6 +310,10 @@ public class JspCompilationContext {
return this.tagJar;
}
+ public void setTagFileJar(Jar tagJar) {
+ this.tagJar = tagJar;
+ }
+
/* ==================== Common implementation ==================== */
/**
Modified: tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java?rev=1662200&r1=1662199&r2=1662200&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
(original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java Wed Feb
25 11:23:00 2015
@@ -554,6 +554,10 @@ class TagFileProcessor {
// time the tag file was scanned for directives, and the
tag
// file may have been modified since then.
wrapper.getJspEngineContext().setTagInfo(tagInfo);
+ // The tagJar passed to to the JspCompilationContext will
+ // have been closed (see the finally block at the end of
+ // this method) so update the the tagJar to one opened
above
+ wrapper.getJspEngineContext().setTagFileJar(tagJar);
}
Class<?> tagClazz;
Modified: tomcat/trunk/test/org/apache/jasper/TestJspCompilationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/TestJspCompilationContext.java?rev=1662200&r1=1662199&r2=1662200&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/TestJspCompilationContext.java
(original)
+++ tomcat/trunk/test/org/apache/jasper/TestJspCompilationContext.java Wed Feb
25 11:23:00 2015
@@ -16,6 +16,8 @@
*/
package org.apache.jasper;
+import java.io.File;
+
import javax.servlet.http.HttpServletResponse;
import org.junit.Assert;
@@ -36,6 +38,36 @@ public class TestJspCompilationContext e
"/test/jsp/tagFileInJar.jsp", body, null);
Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+ Assert.assertTrue(body.toString().contains("00 - OK"));
+ }
+
+
+ /*
+ * Test case for https://bz.apache.org/bugzilla/show_bug.cgi?id=57626
+ */
+ @Test
+ public void testModifiedTagFileInJar() throws Exception {
+ getTomcatInstanceTestWebapp(false, true);
+
+ ByteChunk body = new ByteChunk();
+
+ int rc = getUrl("http://localhost:" + getPort() +
+ "/test/jsp/tagFileInJar.jsp", body, null);
+
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+ Assert.assertTrue(body.toString().contains("00 - OK"));
+
+ File jsp = new File("test/webapp/jsp/tagFileInJar.jsp");
+ jsp.setLastModified(jsp.lastModified() + 10000);
+
+ // This test requires that modificationTestInterval is set to zero in
+ // web.xml. If not, a sleep longer that modificationTestInterval is
+ // required here.
+
+ rc = getUrl("http://localhost:" + getPort() +
+ "/test/jsp/tagFileInJar.jsp", body, null);
+
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
Assert.assertTrue(body.toString().contains("00 - OK"));
}
}
Modified: tomcat/trunk/test/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/WEB-INF/web.xml?rev=1662200&r1=1662199&r2=1662200&view=diff
==============================================================================
--- tomcat/trunk/test/webapp/WEB-INF/web.xml (original)
+++ tomcat/trunk/test/webapp/WEB-INF/web.xml Wed Feb 25 11:23:00 2015
@@ -28,6 +28,25 @@
required.
</description>
+ <servlet>
+ <servlet-name>jsp</servlet-name>
+ <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+ <init-param>
+ <param-name>fork</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <init-param>
+ <param-name>xpoweredBy</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <!-- Required by /jsp/tagFileInJar.jsp / TestJspCompilationContext -->
+ <init-param>
+ <param-name>modificationTestInterval</param-name>
+ <param-value>0</param-value>
+ </init-param>
+ <load-on-startup>3</load-on-startup>
+ </servlet>
+
<!-- Bug 49922 -->
<filter>
<filter-name>Bug49922</filter-name>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]