fleetd #535: convert FleetdLeadMailboxSelectionTest to CapturedLog #536
Reference in New Issue
Block a user
Delete Branch "worker/535-appender-leak-fe74c1-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes fleetd #535.
Three call sites in FleetdLeadMailboxSelectionTest (captureFleetdLogs, formerly at :55-61) attached a ListAppender to the Fleetd.class logger via addAppender and never detached it, and never called appender.setContext(...) either. Logback Logger instances are cached per class and shared for the whole JVM, and surefire reuses forks, so all three appenders stayed attached for every later test in the same fork.
Converted all three call sites to CapturedLog.of(Fleetd.class) (the shared helper added in #533) via try-with-resources, which detaches the appender and restores context for free. Deleted captureFleetdLogs(); nothing calls it now.
This is a hygiene fix, not a correctness bug: no level was pinned, so no other test's level-dependent assertion could be corrupted, and each call made a fresh appender so no cross-test assertion contamination was possible either. The harm was unbounded accumulation of Fleetd.class log events in three untracked lists, and standing as a template that would reintroduce fleetd #525 if someone later added a level pin here.
Tests
mvn -f fleetd/pom.xml clean install: BUILD SUCCESS, Tests run: 1701, Failures: 0, Errors: 0, Skipped: 0 (same total as before the conversion).7d71194).