marcsaeg    01/02/22 08:36:03

  Modified:    src/share/org/apache/jasper/servlet Tag: tomcat_32
                        JspServlet.java
  Log:
  Fixes two thread concurrency problems.
  
  1)  ctxt.createCompiler() invokes JspCompiler constructor that in turn calls 
ClassName.getClassName().  This method opens the JSP page's servlet
  .class file and extracts information about the class name, version, etc.  While the 
class file is open, if the Compiler.compile method is invoked on a different thread 
then it will fail to rename the newly compiled .class file and throw a JasperException.
  
  2)  The value of outDated is first set by calling compiler.compile().  This is 
wrong.  The whole point of this outdated testing is to synchronize the compilation 
process to avoid multiple threads from compiling the same JSP page at the same time so 
putting a call to Compiler.compile() outside the synchronized block defaults the 
point.  outDated should be checked using compiler.isOutDated() instead.
  
  PR: Bugzilla 80/BugRat 44
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.4   +7 -5      
jakarta-tomcat/src/share/org/apache/jasper/servlet/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/jasper/servlet/JspServlet.java,v
  retrieving revision 1.3.2.3
  retrieving revision 1.3.2.4
  diff -u -r1.3.2.3 -r1.3.2.4
  --- JspServlet.java   2001/01/05 18:09:10     1.3.2.3
  +++ JspServlet.java   2001/02/22 16:36:01     1.3.2.4
  @@ -456,14 +456,16 @@
                                                        req, res);
        boolean outDated = false; 
   
  -        Compiler compiler = ctxt.createCompiler();
  +     Compiler compiler = null;
  +     synchronized(this){
  +             compiler = ctxt.createCompiler();
  +     }
           
           try {
  -            outDated = compiler.compile();
  -            if ( (jsw.servletClass == null) || (compiler.isOutDated()) ) {
  +            outDated = compiler.isOutDated();
  +            if ( (jsw.servletClass == null) || outDated ) {
                   synchronized ( this ) {
  -                    if ((jsw.servletClass == null) ||
  -                     (compiler.isOutDated() ))  {
  +                    if ((jsw.servletClass == null) || (compiler.isOutDated() ))  {
                           outDated = compiler.compile();
                       }
                }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to