tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper JspCompilationContext.java
Date Wed, 08 Oct 2003 17:39:15 GMT
kinman      2003/10/08 10:39:15

  Modified:    jasper2/src/share/org/apache/jasper
                        JspCompilationContext.java
  Log:
  - Serialize directory creating to avoid a potential race condition.
  
  Revision  Changes    Path
  1.43      +21 -19    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java
  
  Index: JspCompilationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- JspCompilationContext.java	30 Jul 2003 17:33:14 -0000	1.42
  +++ JspCompilationContext.java	8 Oct 2003 17:39:15 -0000	1.43
  @@ -1,5 +1,6 @@
   /*
  - * $Header$
  + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/
  +JspCompilationContext.java,v 1.42 2003/07/30 17:33:14 kinman Exp $
    * $Revision$
    * $Date$
    *
  @@ -423,10 +424,8 @@
               servletJavaFileName =
   		getOutputDir() + getServletClassName() + ".java";
           } else {
  -            File outDirFile = new File(outputDir);
  -            if (!outDirFile.exists()) {
  -                outDirFile.mkdirs();
  -            }
  +            // Make sure output dir exists
  +            makeOutputDir();
           }
           return servletJavaFileName;
       }
  @@ -474,10 +473,8 @@
           if (classFileName == null) {
               classFileName = getOutputDir() + getServletClassName() + ".class";
           } else {
  -            File outDirFile = new File(outputDir);
  -            if (!outDirFile.exists()) {
  -                outDirFile.mkdirs();
  -            }
  +            // Make sure output dir exists
  +            makeOutputDir();
           }
           return classFileName;
       }
  @@ -594,8 +591,18 @@
           return servletClass;
       }
   
  -    private void createOutputDir() {
  +    // ==================== Private methods ==================== 
   
  +    static Object outputDirLock = new Object();
  +
  +    private void makeOutputDir() {
  +        synchronized(outputDirLock) {
  +            File outDirFile = new File(outputDir);
  +            outDirFile.mkdirs();
  +        }
  +    }
  +
  +    private void createOutputDir() {
           String path = null;
           if (isTagFile()) {
   	    String tagName = tagInfo.getTagClassName();
  @@ -610,19 +617,14 @@
               baseUrl = options.getScratchDir().toURL();
               String outUrlString = baseUrl.toString() + '/' + path;
               URL outUrl = new URL(outUrlString);
  -            File outDirFile = new File(outUrl.getFile());
  -            if (!outDirFile.exists()) {
  -                outDirFile.mkdirs();
  -            }
  -            outputDir = outDirFile.toString() + File.separator;
  +            outputDir = outUrl.getFile() + File.separator;
  +            makeOutputDir();
           } catch (Exception e) {
               throw new IllegalStateException("No output directory: " +
                                               e.getMessage());
           }
       }
       
  -    // ==================== Private methods ==================== 
  -
       private static final boolean isPathSeparator(char c) {
          return (c == '/' || c == '\\');
       }
  
  
  

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


Mime
View raw message