geirm 01/07/28 05:05:50
Modified: src/java/org/apache/velocity/runtime/resource Resource.java
Log:
Fix for the problem reported by Andreas Wikberger <[EMAIL PROTECTED]> whereas
when caching, it required two hits to the template to see it because of a
bug in the cache check logic.
This eliminated the 'lastCheck' member - it doesn't appear to serve any
purpose as we don't need to remember the last check time, but rather
compare 'now' against the nextCheck time.
If there is a flaw in this logic, let me know.
Revision Changes Path
1.7 +6 -21
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/Resource.java
Index: Resource.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/Resource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Resource.java 2001/07/16 16:04:03 1.6
+++ Resource.java 2001/07/28 12:05:50 1.7
@@ -73,7 +73,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Resource.java,v 1.6 2001/07/16 16:04:03 dlr Exp $
+ * @version $Id: Resource.java,v 1.7 2001/07/28 12:05:50 geirm Exp $
*/
public abstract class Resource
{
@@ -104,12 +104,6 @@
* The next time the file modification time will be checked (in
* milliseconds).
*/
- protected long lastCheck = 0;
-
- /**
- * The next time the file modification time will be checked (in
- * milliseconds).
- */
protected long nextCheck = 0;
/**
@@ -167,28 +161,19 @@
}
/*
- * otherwise, see where we are
+ * see if we need to check now
*/
- if ( lastCheck >= nextCheck)
- {
- return true;
- }
- else
- {
- lastCheck = System.currentTimeMillis();
- return false;
- }
+ return (System.currentTimeMillis() >= nextCheck );
}
/**
- * Touch this template and thereby resetting
- * the lastCheck, and nextCheck fields.
+ * 'Touch' this template by resetting
+ * the nextCheck field.
*/
public void touch()
{
- lastCheck = System.currentTimeMillis();
- nextCheck = lastCheck + ( MILLIS_PER_SECOND * modificationCheckInterval);
+ nextCheck = System.currentTimeMillis() + ( MILLIS_PER_SECOND *
modificationCheckInterval);
}
/**