Closed
Description
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]