DelayHandler with MessageStore releases messages too soon.
Consider a messages which get persisted in a delayer's message store with an expression equal to a Date (indicating the time when it should be released).
Then the system is shutdown for maintenance, and turned back on e.g. 2 hours later.
On startup of the system, on ApplicationContextRefreshed DelayHandler.reschedulePersistentMessages is called. It will iterate over the persisted messages, determine the delay when they should be released and schedule this release.
However, in determining the delay, the current Date is compared to the expressions Date object, and in the scheduling, the schedule Date is created by adding the difference to the Request Date instead of the Current Date.
As a result, message are released too soon.
Message in store with Request date 10am and "Delay" header 2pm. Current time 10am. System is shutdown.
At 1pm the system is brought back up.
The determineDelayForMessage will calculate a delay equal to 1 hour in milliseconds (2pm - 1pm). Then releaseMessageAfterDelay will schedule the message for release at 11am (10am + 1h), which will fire right away because it already passed. If the system wasn't restarted, the message would stay in the store until 2pm.
Can be fixed by either calculating delay relative to request time or by scheduling relative from current time instead of request time DelayHandler