https://issues.apache.org/bugzilla/show_bug.cgi?id=52744

             Bug #: 52744
           Summary: [Jasper] JSP files are always recompiled in
                    development mode
           Product: Tomcat 7
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: forres...@gmail.com
    Classification: Unclassified


Steps to reproduce:
1. Have a simple sample application which includes some jsp files
2. Deploy it into tomcat and make it running successfully
3. Stop the server and enable JspServlet development mode
4. In this mode, try to reload the jsp page from the browser
5. Have a debugger attached to the server jvm, set a breakpoint in the jasper
Compiler isOutDated method
6. You will see the jsp file is always be recompiled even there is nothing
changed on it.

Reason analysis: 

The code logic below in the isOutDated(boolean checkClass) method:

Long jspRealLastModified = ctxt.getLastModified(ctxt.getJspFile());
        if (jspRealLastModified.longValue() < 0) {
            // Something went wrong - assume modification
            return true;
        }

        long targetLastModified = 0;
        File targetFile;

        if (checkClass) {
            targetFile = new File(ctxt.getClassFileName());
        } else {
            targetFile = new File(ctxt.getServletJavaFileName());
        }

        if (!targetFile.exists()) {
            return true;
        }

        targetLastModified = targetFile.lastModified();
        if (checkClass && jsw != null) {
            jsw.setServletClassLastModifiedTime(targetLastModified);
        }
        if (targetLastModified != jspRealLastModified.longValue()) {
            if (log.isDebugEnabled()) {
                log.debug("Compiler: outdated: " + targetFile + " "
                        + targetLastModified);
            }
            return true;
        }

Which relies on File.lastModified() method to do comparation, while searched
the web, and got this url[1]

[1]
http://www.coderanch.com/t/384700/java/java/File-lastModified-windows-vs-linux

Which indicates that that method is rounding off the value on the Linux, for
example if a file is modified at 1173423665215 msec, the above method is
returning the value 1173423665000 on linux.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to