Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1445

OnStartupTriggeringPolicyTest fails on Windows saying the file is used by another process

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.6.2
    • Fix Version/s: 2.6.2
    • Component/s: Core
    • Labels:
      None
    • Environment:

      Windows 10, JDK 8

      Description

      I saw some mention on the mailing list that some tests were failing on Windows and thought I'd give a look.
      Effectively OnStartupTriggeringPolicyTest is failing on Windows with:
      java.nio.file.FileSystemException:
      target\testfile: Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus.
      at org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicyTest.cleanup(OnStartupTriggeringPolicyTest.java:77)

      This can be solved by ending the test with:
      manager.release();

      And is due to RollingFileManagerFactory.createManager(..) using new FileOutputStream(..) which eventually calls Windows API CreateFileW(..) without the FILE_SHARE_DELETE flag which prevent other calls to delete the file.

      (Files.newOutputStream(..) eventually does the opposite)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lhochet Ludovic HOCHET
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: