tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 51704] New: Dubious use of mkdirs() return code in juli FileHandler
Date Mon, 22 Aug 2011 13:17:27 GMT

             Bug #: 51704
           Summary: Dubious use of mkdirs() return code in juli
           Product: Tomcat 7
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
    Classification: Unclassified

File#mkdirs() only returns true if the method created the directory itself.

If mkdirs() returns false, it is still possible for the directory to exist.

Thus the code in FileHandler at [1], i.e.

364     // Create the directory if necessary
365     File dir = new File(directory);
366     if (!dir.exists() && !dir.mkdirs()) {
367         reportError("Unable to create [" + dir + "]", null,
368         ErrorManager.OPEN_FAILURE);
369         writer = null;
370         return;
371     }

can generate an error even though the directory now exists.

It would be safer to code the check as follows:

366     if (!dir.mkdirs() && !dir.exists()) {

There is no need to call dir.exists() before mkdirs() as mkdirs() does that

There is similar code at [2] and possibly elsewhere in Tomcat, I did not check.



Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message