Skip to content

ArithmeticException: long overflow on @Scheduled(fixedDelay = Long.MAX_VALUE) #30754

Closed
@ipalbeniz

Description

@ipalbeniz

Affects: 6.0.10


I was scheduling a task using @Scheduled(fixedDelay = Long.MAX_VALUE) in Spring version 6.0.9. The intention was to schedule the task only once. However, after upgrading to version 6.0.10, the application fails to start with the following exception:

java.lang.ArithmeticException: long overflow
	at java.base/java.lang.Math.multiplyExact(Math.java:1004)
	at java.base/java.time.Duration.toNanos(Duration.java:1250)
	at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.scheduleWithFixedDelay(ThreadPoolTaskScheduler.java:420)

It seems that the method ThreadPoolTaskScheduler.scheduleWithFixedDelay() was changed in commit 3415b04, which is referenced by issue #30666. This change modifies the delay time unit from milliseconds to nanoseconds. I suspect that this alteration may be the cause of the exception.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions