I have an application currently running on Springboot 3.1.2. The app having @Scheduled method with cron expression.
As soon as I update the spring-boot version to 3.2.2 the first execution happens immediately after the application startup.
If I switch back to 3.1.2 this doesn't happen and the scheduled job executes only at the time defined in CRON.
Is there something that we have to take care during the upgrade.
Method :
@Scheduled(cron = "${cron.expression.maximize-value}", zone = "${cron.timezone}") public Flux
The class is annotated with @Service.
Comment From: bclozel
Before Spring Framework 6.1, @Scheduled
methods returning a Publisher
type were not supported. In your case, the method itself was executed but the returned publisher was never subscribed to.
As of #29924 this is now supported. This means that such methods are executed right away to get the publisher and then schedule its subscription when the cron is due. Maybe your scheduled method has a log statement in it? In any case, a method returning a Publisher should be lazy and should not have side effects before subscription happens.
See the reference documentation for more on that.
I'm closing this issue as it works as expected.