vy commented on code in PR #3946:
URL: https://github.com/apache/logging-log4j2/pull/3946#discussion_r2440047760
##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java:
##########
Review Comment:
Does this serve any purpose related with the `RollingAppenderDirectCronTest`
fix? If not, please revert this incidental change.
##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectCronTest.java:
##########
@@ -102,16 +102,18 @@ public void rolloverComplete(final String fileName) {
final Path path = Paths.get(fileName);
final Matcher matcher =
FILE_PATTERN.matcher(path.getFileName().toString());
assertThat(matcher).as("Rolled file").matches();
- try {
- 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());
- }
+
+ // Wait until the file is non-empty (or timeout)
+ waitAtMost(2, TimeUnit.SECONDS).until(() -> Files.exists(path)
&& Files.size(path) > 0);
+
+ final List<String> lines = Files.readAllLines(path);
+ assertThat(lines).isNotEmpty();
+ assertThat(lines.get(0)).startsWith(matcher.group(1));
Review Comment:
Could you instead move the assertion block inside a
`waitAtMost(Duration.ofSeconds(5)).untilAsserted(...)`, please?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]