Skip to content

ScheduledTasksEndpoint throws NPE if PeriodicTrigger is used with custom SchedulingConfigurer #36081

@ztomic

Description

@ztomic

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

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions