You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/10/22 11:56:01 UTC

DO NOT REPLY [Bug 13843] New: - Jasper locks big files at runtime

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13843>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13843

Jasper locks big files at runtime

           Summary: Jasper locks big files at runtime
           Product: Tomcat 4
           Version: 4.1.12
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper 2
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: cmarton@calendra.com


Some JSP are locked by Tomcat at runtime. The file is locked after the first
access to the web page with the browser.

After investigation I found that the following code performs the lock on some
files: 

Class org.apache.servlet.JspServlet

private void serviceJspFile(HttpServletRequest request,
                                HttpServletResponse response, String jspUri,
                                Throwable exception, boolean precompile)
        throws ServletException, IOException {

   JspServletWrapper wrapper =
            (JspServletWrapper) rctxt.getWrapper(jspUri);
   if (wrapper == null) {
       // First check if the requested JSP page exists, to avoid
       // creating unnecessary directories and files.
            
       if (context.getResourceAsStream(jspUri)== null) {
              response.sendError(HttpServletResponse.SC_NOT_FOUND, jspUri);
              return;
       }
       .....


context.getResourceAsStream(jspUri) locks some files on Windows. It seems to be
related to file size. I tried on a dumb big page filled with only text (50ko):
it locks, with the same page with less text (5ko) the page is not locked.

As a concequence, the opened inputStream should be closed even if it is not read.
The following code do not lock files anymore:

   java.io.InputStream resourceStream=context.getResourceAsStream(jspUri);
   if (resourceStream == null) {
       response.sendError(HttpServletResponse.SC_NOT_FOUND, jspUri);
       return;
    }else{
        try{
            resourceStream.close();
        }catch(IOException e) { /* ignore */ }
    }

IMPORTANT: to reproduce problem. Files seems not be locked on a new compiled
page. After modiying a JSP, restart Tomcat, access the web page and check if you
can rename the corresponding JSP file.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>