Under certain conditions, the resource cache implementation used by the servlet/JSP engine (in org.apache.naming.resource) does not detect that a file in its cache has been modified and therefore returns the previous contents of the file. This happens only * when the file contents are modified but the file length doesn't change * until the time the first change in the file is detected after server startup To reproduce the problem, put the attached test.jsp and test.txt into the ROOT web app and then do the following. (I used Tomcat 6's trunk for the test) % cat test.txt abcd % telnet . 9080 Trying 0.0.0.0... Connected to .. Escape character is '^]'. GET /test.jsp HTTP/1.0 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=706D6FE8B06687509D42E79DBEE266EF; Path=/ Content-Type: text/html Content-Length: 26 Date: Wed, 23 May 2007 23:03:05 GMT Connection: close File contents=[ abcd ] Connection to . closed by foreign host. % cat test.txt (change the contents but not the size) efgh % telnet . 9080 Trying 0.0.0.0... Connected to .. Escape character is '^]'. GET /test.jsp HTTP/1.0 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=2B144247B747F54184114FA82869DE14; Path=/ Content-Type: text/html Content-Length: 26 Date: Wed, 23 May 2007 23:04:24 GMT Connection: close File contents=[ abcd ]
Created attachment 20263 [details] Data file for the test case Put test.txt in the ROOT web app
Created attachment 20264 [details] Test case Put test.jsp in the ROOT web app.
Created attachment 20265 [details] Patch that updates the last modified time of the file when it is inserted into the cache The problem occurs because the last modified timestamp in the FileResourceAttribute of CacheEntry isn't updated at the time the CacheEntry is first inserted into the cache. The timestamp gets updated when ProxyDirContext.revalidate() is executed. The window between when the CacheEntry was inserted and when ProxyDirContext.revalidate() is called is where the problem occurs. The attached patch fixes this by updating the last modified (and creation) timestamp at the time the resource is created (i.e. inserted into the cache).
patch applied to trunk pending vote for 6.0.x
The vote passed and the patch has been applied. It will be included in 6.0.16 onwards.