Skip to content

ArithmeticException: long overflow on @Scheduled(fixedDelay = Long.MAX_VALUE, timeUnit = TimeUnit.MINUTES)  #31210

Closed
@marceloverdijk

Description

@marceloverdijk

This is similar as #30754

Note I can confirm the original issue is solved in Spring 6.0.11 as this works:

@Scheduled(initialDelay = 5, fixedDelay = Long.MAX_VALUE)

but using:

@Scheduled(initialDelay = 5, fixedDelay = Long.MAX_VALUE, timeUnit = TimeUnit.MINUTES)

still gives the ArithmeticException:

Caused by: java.lang.ArithmeticException: long overflow
	at java.base/java.lang.Math.multiplyExact(Math.java:1004) ~[na:na]
	at java.base/java.time.Duration.plus(Duration.java:729) ~[na:na]
	at java.base/java.time.Duration.of(Duration.java:312) ~[na:na]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.toDuration(ScheduledAnnotationBeanPostProcessor.java:535) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.processScheduled(ScheduledAnnotationBeanPostProcessor.java:452) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.lambda$postProcessAfterInitialization$1(ScheduledAnnotationBeanPostProcessor.java:377) ~[spring-context-6.0.11.jar:6.0.11]
	at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.lambda$postProcessAfterInitialization$2(ScheduledAnnotationBeanPostProcessor.java:377) ~[spring-context-6.0.11.jar:6.0.11]
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[na:na]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization(ScheduledAnnotationBeanPostProcessor.java:376) ~[spring-context-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1773) ~[spring-beans-6.0.11.jar:6.0.11]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.11.jar:6.0.11]

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions