Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ztomic opened this issue Jun 27, 2023 · 1 comment
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@ztomic
Copy link
Contributor

ztomic commented Jun 27, 2023

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 27, 2023
@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 27, 2023
@mhalbritter mhalbritter added this to the 3.0.x milestone Jun 27, 2023
@wilkinsona
Copy link
Member

I think this is a regression as it's fine in 2.7.x. The changes in efc5391 didn't take into account that getInitialDelayDuration() is nullable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants