Author: markt Date: Thu Feb 21 14:42:00 2008 New Revision: 630034 URL: http://svn.apache.org/viewvc?rev=630034&view=rev Log: Fix for bug 43741. Correctly handle dependencies for tag files in JARs.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=630034&r1=630033&r2=630034&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java Thu Feb 21 14:42:00 2008 @@ -284,9 +284,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)); } @@ -559,7 +579,7 @@ public void compile() throws JasperException, FileNotFoundException { createCompiler(); - if (isPackagedTagFile || jspCompiler.isOutDated()) { + if (jspCompiler.isOutDated()) { try { jspCompiler.removeGeneratedFiles(); jspLoader = null; Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=630034&r1=630033&r2=630034&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java Thu Feb 21 14:42:00 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/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java?rev=630034&r1=630033&r2=630034&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagFileProcessor.java Thu Feb 21 14:42:00 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(), Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=630034&r1=630033&r2=630034&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Thu Feb 21 14:42:00 2008 @@ -54,6 +54,14 @@ </update> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <fix> + <bug>43741</bug>: Correctly handle dependencies for tag files in JARs. + (markt) + </fix> + </changelog> + </subsection> <subsection name="Cluster"> <changelog> <update> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]