[logback-dev] [qos-ch/logback] 0637d2: Fix exception when threads write files to same dir

Tony Trinh tony19 at gmail.com
Tue May 27 03:15:39 CEST 2014


  Branch: refs/heads/master
  Home:   https://github.com/qos-ch/logback
  Commit: 0637d22cf8a6c0f41487021c9ff087e8bd256274
      https://github.com/qos-ch/logback/commit/0637d22cf8a6c0f41487021c9ff087e8bd256274
  Author: Tony Trinh <tony19 at gmail.com>
  Date:   2014-05-26 (Mon, 26 May 2014)

  Changed paths:
    M logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
    M logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java
    M logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java
    M logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
    M logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
    M logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java

  Log Message:
  -----------
  Fix exception when threads write files to same dir

When Multiple FileAppenders attempt to write files to the same
nonexistent directory, concurrent threads could attempt to create
the directory at the same time, where only one succeeds, while
the others hit an IllegalStateException. This patch modifies
FileUtil.createMissingParentDirectories() to gracefully handle
existing directories (no exceptions thrown).

This patch also removes FileUtil.isParentDirectoryCreationRequired()
as this allows for race conditions between the existence-check and
the directory creation. Note that File.mkdirs() already performs
an existence-check.

Fixes LOGBACK-128




More information about the logback-dev mailing list