Author: markt
Date: Mon Feb 4 14:58:21 2008
New Revision: 618481
URL: http://svn.apache.org/viewvc?rev=618481&view=rev
Log:
Fix for bug 43741. Correctly handle dependencies for tag files in JARs.
Modified:
tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=618481&r1=618480&r2=618481&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java Mon Feb 4
14:58:21 2008
@@ -279,9 +279,29 @@
public URL getResource(String res) throws MalformedURLException {
- return context.getResource(canonicalURI(res));
+ URL result = null;
+
+ if (res.startsWith("/META-INF/")) {
+ // This is a tag file packaged in a jar that is being compiled
+ URL jarUrl = tagFileJarUrls.get(res);
+ if (jarUrl == null) {
+ jarUrl = tagFileJarUrl;
+ }
+ if (jarUrl != null) {
+ result = new URL(jarUrl.toExternalForm() + res.substring(1));
+ }
+ } else if (res.startsWith("jar:file:")) {
+ // This is a tag file packaged in a jar that is being checked
+ // for a dependency
+ result = new URL(res);
+
+ } else {
+ result = context.getResource(canonicalURI(res));
+ }
+ return result;
}
+
public Set getResourcePaths(String path) {
return context.getResourcePaths(canonicalURI(path));
}
@@ -554,7 +574,7 @@
public void compile() throws JasperException, FileNotFoundException {
createCompiler();
- if (isPackagedTagFile || jspCompiler.isOutDated()) {
+ if (jspCompiler.isOutDated()) {
try {
jspCompiler.removeGeneratedFiles();
jspLoader = null;
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=618481&r1=618480&r2=618481&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Mon Feb 4
14:58:21 2008
@@ -23,6 +23,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
@@ -384,7 +385,12 @@
return false;
}
URLConnection uc = jspUrl.openConnection();
- jspRealLastModified = uc.getLastModified();
+ if (uc instanceof JarURLConnection) {
+ jspRealLastModified =
+ ((JarURLConnection) uc).getJarEntry().getTime();
+ } else {
+ jspRealLastModified = uc.getLastModified();
+ }
uc.getInputStream().close();
} catch (Exception e) {
return true;
@@ -435,9 +441,15 @@
return true;
}
- URLConnection includeUconn = includeUrl.openConnection();
- long includeLastModified = includeUconn.getLastModified();
- includeUconn.getInputStream().close();
+ URLConnection iuc = includeUrl.openConnection();
+ long includeLastModified = 0;
+ if (iuc instanceof JarURLConnection) {
+ includeLastModified =
+ ((JarURLConnection) iuc).getJarEntry().getTime();
+ } else {
+ includeLastModified = iuc.getLastModified();
+ }
+ iuc.getInputStream().close();
if (includeLastModified > targetLastModified) {
return true;
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=618481&r1=618480&r2=618481&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
(original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java Mon Feb
4 14:58:21 2008
@@ -619,9 +619,18 @@
TagFileInfo tagFileInfo = n.getTagFileInfo();
if (tagFileInfo != null) {
String tagFilePath = tagFileInfo.getPath();
- JspCompilationContext ctxt = compiler.getCompilationContext();
- if (ctxt.getTagFileJarUrl(tagFilePath) == null) {
- // Omit tag file dependency info on jar files for now.
+ if (tagFilePath.startsWith("/META-INF/")) {
+ // For tags in JARs, add the TLD and the tag as a
dependency
+ String[] location =
+ compiler.getCompilationContext().getTldLocation(
+ tagFileInfo.getTagInfo().getTagLibrary().getURI());
+ // Add TLD
+ pageInfo.addDependant("jar:" + location[0] + "!/" +
+ location[1]);
+ // Add Tag
+ pageInfo.addDependant("jar:" + location[0] + "!" +
+ tagFilePath);
+ } else {
pageInfo.addDependant(tagFilePath);
}
Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]