Skip to content

Conversation

rjuare8
Copy link

@rjuare8 rjuare8 commented Oct 3, 2025

Stabilize RollingAppenderDirectCronTest by waiting for rolled file content and relaxing rollover timeout
Addresses #3046.

Important

Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise.

This PR hardens RollingAppenderDirectCronTest against timing races observed with cron-based rollovers. In practice, rolloverComplete(...) can fire before the first write to the newly rolled file has reached disk, causing the test to intermittently assert on an empty file. Under scheduler jitter, the test could also time out while waiting for a rollover.

What changed (test-only)

  • In rolloverComplete(...), wait briefly until the rolled file exists and has non-zero length before asserting its contents:
    waitAtMost(2, TimeUnit.SECONDS).until(() -> Files.exists(path) && Files.size(path) > 0);

Why

Checklist

Before we can review and merge your changes, please go through the checklist below. If you're still working on some items, feel free to submit your pull request as a draft—our CI will help guide you through the remaining steps.

✅ Required checks

  • License: I confirm that my changes are submitted under the Apache License, Version 2.0.

  • Commit signatures: All commits are signed and verifiable. (See GitHub Docs on Commit Signature Verification).

  • Code formatting: The code is formatted according to the project’s style guide.

    How to check and fix formatting
    • To check formatting: ./mvnw spotless:check
    • To fix formatting: ./mvnw spotless:apply

    See the build instructions for details.

  • Build & Test: I verified that the project builds and all unit tests pass.

    How to build the project

    Run: ./mvnw verify

    See the build instructions for details.

🧪 Tests (select one)

  • I have added or updated tests to cover my changes.
  • ✅ No additional tests are needed for this change.

📝 Changelog (select one)

  • I added a changelog entry in src/changelog/.2.x.x. (See Changelog Entry File Guide).
  • ✅ This is a trivial change and does not require a changelog entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

1 participant