Author: wglass Date: Tue Jan 3 21:30:46 2006 New Revision: 365829 URL: http://svn.apache.org/viewcvs?rev=365829&view=rev Log: Correct fix to VELOCITY-98. If page writer alternates #parse and #include for the same file, the file needs to be reloaded (can't reuse the cache).
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?rev=365829&r1=365828&r2=365829&view=diff ============================================================================== --- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java (original) +++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java Tue Jan 3 21:30:46 2006 @@ -22,6 +22,7 @@ import java.io.InputStream; import java.io.IOException; +import org.apache.velocity.Template; import org.apache.velocity.runtime.log.Log; import org.apache.velocity.runtime.RuntimeServices; import org.apache.velocity.runtime.RuntimeConstants; @@ -294,6 +295,23 @@ Resource resource = globalCache.get(resourceName); + /** + * Check to see if the type has changed and reload the file if so. + * For example, if a file has been loaded with #include and then #parse + * If so, reload the resource. + * + * Note that if a page repeatedly alternates #include and #parse + * on the same file the cache is essentially negated. + */ + if ( resource != null ) + { + if ( ((resourceType == RESOURCE_CONTENT) && !(resource instanceof ContentResource)) || + ((resourceType == RESOURCE_TEMPLATE) && !(resource instanceof Template)) ) + { + resource = null; + } + } + if( resource != null) { /* --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]