Description
Log4j2EventListener carries @ConditionalOnProperty("spring.cloud.config.watch.enabled") but always runs.
It is registered twice:
- as
@Component — the condition applies
- in
META-INF/spring.factories (line 17) as an ApplicationListener — the condition cannot apply, because SpringApplication instantiates these directly, with no bean definition to suppress
So spring.cloud.config.watch.enabled=false disables nothing.
Version: 2.x 04c93c1d33 · JDK 21 · Spring Boot 3.4.3
Logs
Property set to false, monitorInterval 300s:
RELOADED - the refresh event drove the reload, 298 seconds before
the monitorInterval would have
298s ahead of the interval, so the event drove it, not the timer.
Reproduction
Run with -Dspring.cloud.config.watch.enabled=false and publish an EnvironmentChangeEvent (POST /actuator/refresh). Log4j reconfigures anyway.
Suggested fix
Check the property inside onApplicationEvent against the Environment — smallest change, keeps the documented switch meaningful. Or drop @ConditionalOnProperty so the source stops promising a switch that does not exist.
Description
Log4j2EventListenercarries@ConditionalOnProperty("spring.cloud.config.watch.enabled")but always runs.It is registered twice:
@Component— the condition appliesMETA-INF/spring.factories(line 17) as anApplicationListener— the condition cannot apply, becauseSpringApplicationinstantiates these directly, with no bean definition to suppressSo
spring.cloud.config.watch.enabled=falsedisables nothing.Version: 2.x
04c93c1d33· JDK 21 · Spring Boot 3.4.3Logs
Property set to
false,monitorInterval300s:298s ahead of the interval, so the event drove it, not the timer.
Reproduction
Run with
-Dspring.cloud.config.watch.enabled=falseand publish anEnvironmentChangeEvent(POST/actuator/refresh). Log4j reconfigures anyway.Suggested fix
Check the property inside
onApplicationEventagainst theEnvironment— smallest change, keeps the documented switch meaningful. Or drop@ConditionalOnPropertyso the source stops promising a switch that does not exist.