Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 91367 invoked from network); 8 Oct 2003 17:39:23 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 8 Oct 2003 17:39:23 -0000 Received: (qmail 86298 invoked by uid 500); 8 Oct 2003 17:39:08 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 86253 invoked by uid 500); 8 Oct 2003 17:39:07 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 86236 invoked by uid 500); 8 Oct 2003 17:39:07 -0000 Received: (qmail 86233 invoked from network); 8 Oct 2003 17:39:07 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 8 Oct 2003 17:39:07 -0000 Received: (qmail 91329 invoked by uid 1384); 8 Oct 2003 17:39:15 -0000 Date: 8 Oct 2003 17:39:15 -0000 Message-ID: <20031008173915.91328.qmail@minotaur.apache.org> From: kinman@apache.org To: jakarta-tomcat-jasper-cvs@apache.org Subject: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper JspCompilationContext.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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