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

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


The following commit(s) were added to refs/heads/2.x by this push:
     new 60c62ee8fd Stabilize `RollingAppenderDirectCronTest` and 
`XmlCompleteFileAppenderTest` (#3946)
60c62ee8fd is described below

commit 60c62ee8fd49639f59cf4673c75fa3bf9b055c48
Author: Rodolfo Juarez <[email protected]>
AuthorDate: Wed Oct 22 05:47:46 2025 -0500

    Stabilize `RollingAppenderDirectCronTest` and `XmlCompleteFileAppenderTest` 
(#3946)
    
    Co-authored-by: Volkan Yazıcı <[email protected]>
---
 .../core/appender/XmlCompleteFileAppenderTest.java  |  6 ++++--
 .../rolling/RollingAppenderDirectCronTest.java      | 21 +++++++++------------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git 
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
 
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
index d5ce1a47e6..c3310ac930 100644
--- 
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
+++ 
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
@@ -82,8 +82,10 @@ public class XmlCompleteFileAppenderTest {
         try (final BufferedReader reader = new BufferedReader(new 
FileReader(logFile))) {
             line1 = reader.readLine();
             line2 = reader.readLine();
-            reader.readLine(); // ignore the empty line after the <Events> root
-            line3 = reader.readLine();
+
+            // Locate the first non-empty line after the `<Events>` root
+            while ((line3 = reader.readLine()) != null && 
line3.trim().isEmpty()) {}
+
             line4 = reader.readLine();
             line5 = reader.readLine();
         } finally {
diff --git 
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectCronTest.java
 
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectCronTest.java
index 6751d3cb1f..444016dfd1 100644
--- 
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectCronTest.java
+++ 
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectCronTest.java
@@ -18,9 +18,7 @@ package org.apache.logging.log4j.core.appender.rolling;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.awaitility.Awaitility.waitAtMost;
-import static org.junit.jupiter.api.Assertions.fail;
 
-import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -70,7 +68,7 @@ class RollingAppenderDirectCronTest {
     private static class RolloverDelay implements RolloverListener {
         private final Logger logger = StatusLogger.getLogger();
         private volatile CountDownLatch latch;
-        private volatile AssertionError assertion;
+        private volatile Exception verificationFailure;
 
         public RolloverDelay(final RollingFileManager manager) {
             latch = new CountDownLatch(1);
@@ -80,9 +78,9 @@ class RollingAppenderDirectCronTest {
         public void waitForRollover() {
             waitAtMost(5, TimeUnit.SECONDS)
                     .alias("Rollover timeout")
-                    .until(() -> latch.getCount() == 0 || assertion != null);
-            if (assertion != null) {
-                throw assertion;
+                    .until(() -> latch.getCount() == 0 || verificationFailure 
!= null);
+            if (verificationFailure != null) {
+                throw new RuntimeException(verificationFailure);
             }
         }
 
@@ -102,16 +100,15 @@ class RollingAppenderDirectCronTest {
                 final Path path = Paths.get(fileName);
                 final Matcher matcher = 
FILE_PATTERN.matcher(path.getFileName().toString());
                 assertThat(matcher).as("Rolled file").matches();
-                try {
+                waitAtMost(2, TimeUnit.SECONDS).untilAsserted(() -> {
                     final List<String> lines = Files.readAllLines(path);
                     assertThat(lines).isNotEmpty();
                     assertThat(lines.get(0)).startsWith(matcher.group(1));
-                } catch (final IOException ex) {
-                    fail("Unable to read file " + fileName + ": " + 
ex.getMessage());
-                }
+                });
                 latch.countDown();
-            } catch (final AssertionError ex) {
-                assertion = ex;
+            } catch (final Exception ex) {
+                verificationFailure =
+                        new RuntimeException("Rollover completion verification 
failure for file: " + fileName, ex);
             }
         }
     }

Reply via email to