Skip to content

Fix the log4j-spring-cloud-config-client test harness - #4317

Merged
ramanathan1504 merged 6 commits into
2.xfrom
fix-spring-cloud-config-client-test-harness
Sep 16, 2026
Merged

ramanathan1504 merged 6 commits into
2.xfrom
fix-spring-cloud-config-client-test-harness

Conversation

@ramanathan1504

Copy link
Copy Markdown
Contributor

Follow-up to @vy's request on #4252. The module has run no tests since removed junit-vintage-engine while Log4j2EventListenerTest stayed on JUnit 4.

After Restoring jave some issues: CONFIG names a file that does not exist, Boot's bundled log4j2.xml claims the LoggerContext first, and no configuration declares monitorInterval, so WatchManager.start() never subscribes to WatchEventManager.

The module has run no tests since `8d706b4b27` (2024-01-04) removed
`junit-vintage-engine` while `Log4j2EventListenerTest` stayed on JUnit 4:
Surefire selects the JUnit Platform provider, discovers nothing and reports
`Tests run: 0` with a green build.

Restoring the engine exposes three further breakages that kept the only
assertion in the module unreachable:

- `CONFIG` named `log4j-console.xml`; the resource is `log4j2-console.xml`.
- `spring-boot-starter-log4j2` is a test dependency, so Boot installs its own
  bundled `log4j2.xml` before `LoggerContextRule` can install the module's.
- Neither configuration declares `monitorInterval`, so
  `AbstractConfiguration.isConfigurationMonitoringEnabled()` is false,
  `WatchManager.start()` never runs, nothing subscribes to
  `WatchEventManager` and `publishEvent()` iterates an empty map.

`logging.config` now points Boot at the module's own configuration and the
test reads the `LoggerContext` that Boot installed, which retires the
`LoggerContextRule` and `RuleChain`. `withCleanFilesRule("target/logs")` is
dropped with them; the configuration declares a single console appender and
has never written there.

Verified: `Tests run: 1, Failures: 0` with both halves in place, and
`Failures: 1` with either `monitorInterval` or the `logging.config` property
removed. Full `verify` on the module is green through spotbugs, RAT, spotless
and bnd-baseline.
@ramanathan1504
ramanathan1504 enabled auto-merge (squash) September 16, 2026 06:26
@ramanathan1504 ramanathan1504 added the tests Pull requests or issues related to tests label Sep 16, 2026
@ramanathan1504
ramanathan1504 merged commit 6ad11e4 into 2.x Sep 16, 2026
7 checks passed
@ramanathan1504
ramanathan1504 deleted the fix-spring-cloud-config-client-test-harness branch September 16, 2026 07:06
@github-project-automation github-project-automation Bot moved this from Approved to Merged in Log4j pull request tracker Sep 16, 2026
@ramanathan1504 ramanathan1504 added this to the 2.26.2 milestone Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port-to-2.26.x port-to-main tests Pull requests or issues related to tests

Projects

Development

Successfully merging this pull request may close these issues.

2 participants