This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/master by this push:
     new b99ead7947 One more change to fix the test
b99ead7947 is described below

commit b99ead7947afa6a1102139131d39be35cb1f9e9d
Author: Ralph Goers <[email protected]>
AuthorDate: Mon Jul 4 22:35:41 2022 -0700

    One more change to fix the test
---
 .../rolling/RollingDirectTimeNewDirectoryTest.java      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectTimeNewDirectoryTest.java
 
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectTimeNewDirectoryTest.java
index 315798750f..f4416fe013 100644
--- 
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectTimeNewDirectoryTest.java
+++ 
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingDirectTimeNewDirectoryTest.java
@@ -28,7 +28,10 @@ import org.opentest4j.AssertionFailedError;
 
 import java.io.File;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -41,6 +44,8 @@ public class RollingDirectTimeNewDirectoryTest implements 
RolloverListener {
     // Note that the path is hardcoded in the configuration!
     private static final String DIR = "target/rolling-folder-direct";
     private final CountDownLatch rollover = new CountDownLatch(2);
+    private boolean isFirst = true;
+    private String ignored = null;
 
     @Test
     @CleanUpDirectories(DIR)
@@ -78,6 +83,11 @@ public class RollingDirectTimeNewDirectoryTest implements 
RolloverListener {
             
assertThat(logFolders).hasSizeGreaterThanOrEqualTo(minExpectedLogFolderCount);
 
             for (File logFolder : logFolders) {
+                // It is possible a log file is created at startup and by he 
time we get here it
+                // has rolled but has no data and so was deleted.
+                if (ignored != null && 
logFolder.getAbsolutePath().equals(ignored)) {
+                    continue;
+                }
                 File[] logFiles = logFolder.listFiles();
                 if (logFiles != null) {
                     Arrays.sort(logFiles);
@@ -111,6 +121,13 @@ public class RollingDirectTimeNewDirectoryTest implements 
RolloverListener {
 
     @Override
     public void rolloverComplete(final String fileName) {
+        File file = new File(fileName);
+        if (isFirst && file.length() == 0) {
+            isFirst = false;
+            ignored = file.getParentFile().getAbsolutePath();
+            return;
+        }
+        isFirst = false;
         rollover.countDown();
     }
 }

Reply via email to