fleetd #535: convert FleetdLeadMailboxSelectionTest to CapturedLog #536

Merged
ltms merged 1 commits from worker/535-appender-leak-fe74c1-1 into main 2026-09-12 08:25:01 +02:00
Member

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).
  • Project-wide addAppender/detachAppender balance: 46/46 (was 47/46 on main at 7d71194).
  • FleetdLeadMailboxSelectionTest: 0 raw addAppender calls remaining.
  • Mutation check (removing detachAppender from CapturedLog.close()): full build stayed green (1701/0/0/0) — nothing in the tree currently exercises the appender-restore half via an assertion. Proved the harness itself can go red first (injected a deliberate false assertion into one of the three converted tests: FAILURE, Tests run: 6, Failures: 1). Reverted both the deliberate failure and the CapturedLog.java mutation; CapturedLog.java hash after restore matches the pristine hash exactly.
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). - Project-wide addAppender/detachAppender balance: 46/46 (was 47/46 on main at 7d71194). - FleetdLeadMailboxSelectionTest: 0 raw addAppender calls remaining. - Mutation check (removing detachAppender from CapturedLog.close()): full build stayed green (1701/0/0/0) — nothing in the tree currently exercises the appender-restore half via an assertion. Proved the harness itself can go red first (injected a deliberate false assertion into one of the three converted tests: FAILURE, Tests run: 6, Failures: 1). Reverted both the deliberate failure and the CapturedLog.java mutation; CapturedLog.java hash after restore matches the pristine hash exactly.
agent added 1 commit 2026-09-12 08:17:43 +02:00
fleetd #535: convert FleetdLeadMailboxSelectionTest to CapturedLog
CI / contract (pull_request) Successful in 53s
CI / build (pull_request) Successful in 1m52s
c7903c1efe
Three call sites (captureFleetdLogs at :55) attached a ListAppender to the
Fleetd.class logger with 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 fork.

Convert all three call sites to CapturedLog.of(Fleetd.class) (added in
#533) via try-with-resources, which detaches the appender and sets the
context for free. Delete captureFleetdLogs(); nothing calls it now.
ltms merged commit f1640f5dcc into main 2026-09-12 08:25:01 +02:00
Sign in to join this conversation.