When using org.springframework.scheduling.support.PeriodicTrigger trigger with custom SchedulingConfigurer NPE is thrown because PeriodicTrigger is without initial duration
11:00:08.565 ERROR [http-nio-9898-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.NullPointerException: Cannot invoke "java.time.Duration.toMillis()" because the return value of "org.springframework.scheduling.support.PeriodicTrigger.getInitialDelayDuration()" is null] with root cause
java.lang.NullPointerException: Cannot invoke "java.time.Duration.toMillis()" because the return value of "org.springframework.scheduling.support.PeriodicTrigger.getInitialDelayDuration()" is null
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint$IntervalTaskDescriptor.<init>(ScheduledTasksEndpoint.java:189)
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint$FixedDelayTaskDescriptor.<init>(ScheduledTasksEndpoint.java:214)
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint$TaskDescriptor.describeTriggerTask(ScheduledTasksEndpoint.java:152)
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint$TaskDescriptor.lambda$static$3(ScheduledTasksEndpoint.java:127)
...
Since PeriodicTrigger.getInitialDelayDuration() is @Nullable, probably IntervalTaskDescriptor should have some sort of null check for that.
Spring Boot 3.1.1, Spring Framework 6.0.10
Comment From: wilkinsona
I think this is a regression as it's fine in 2.7.x. The changes in https://github.com/spring-projects/spring-boot/commit/efc53914968e4eb393275539e70face213c7c8a8 didn't take into account that getInitialDelayDuration() is nullable.