I use CronExpression and have an issue - method executes a few (about 100-300) ms earlier than scheduled. I do understand it is not a realtime, but I use it for a database updates and it will be good at least to make it executing a 100-300ms later but never earlier. Like, in my use case I have an update ... where expire_date < current_timestamp() running by CronExpression's driven ThreadPoolTaskScheduler, which should deactivate an access for the users having their expire_date actually... hmmm... like, expired at the very moment. Of course I can schedule the task as "+1 second" which isn't good but at least better than having this problem, but this thing is end users/admins controlled via frontend and it would be a bit difficult to explain them all, and even more difficult to automatize.

I use: Running with Spring Boot v3.3.0, Spring v6.1.8

Is it possible to fix somehow? Thank you!

Upd: I created a post on stackoverflow, and they told me "it is not a bug but feature". I also found an old bug report regarding that but since I cannot reopen it, I decided to try to explain my reasons in my particular case. Or maybe you could explain in brief where are roots of this problem so I could try to fix it myself. But it is really strange for me - why earlier? I understand there's could be a startup time and so on, which could lead to startup delay and it is understood and acceptable. But early run is totally unexpected, at least for me.

Comment From: snicoll

This was already discussed at length in https://github.com/spring-projects/spring-framework/issues/29735

Comment From: BbIKTOP

Yes, Ive seen that but I just wanted to provide a use case as old one is closed. Along with common sense, this is quite common case i suppose, and it makes CronExpression unusable.