-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Closed
Description
If a custom SchedulingConfigurer is registered with spring boot, then the scheduledtasks actuator will fail with a null pointer exception.
Spring boot 2.1.2
Stack trace:
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Optional.<init>(Optional.java:96)
at java.util.Optional.of(Optional.java:108)
at java.util.stream.FindOps$FindSink$OfRef.get(FindOps.java:193)
at java.util.stream.FindOps$FindSink$OfRef.get(FindOps.java:190)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint$TaskDescription.of(ScheduledTasksEndpoint.java:130)
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint$TaskDescription.access$900(ScheduledTasksEndpoint.java:108)
at org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.lambda$scheduledTasks$1(ScheduledTasksEndpoint.java:63)
The endpoint defined in ScheduledTasksEndpoint.java can only handle CronTrigger's and PeriodicTrigger's. Anything else will cause the endpoint to fail with a null pointer exception
// org.springframework.boot.actuate.scheduling.ScheduleTaskEndpoint.java
private static ScheduledTasksEndpoint.TaskDescription describeTriggerTask(TriggerTask triggerTask) {
Trigger trigger = triggerTask.getTrigger();
if (trigger instanceof CronTrigger) {
return new ScheduledTasksEndpoint.CronTaskDescription(triggerTask, (CronTrigger)trigger);
} else if (trigger instanceof PeriodicTrigger) {
PeriodicTrigger periodicTrigger = (PeriodicTrigger)trigger;
return (ScheduledTasksEndpoint.TaskDescription)(periodicTrigger.isFixedRate() ? new ScheduledTasksEndpoint.FixedRateTaskDescription(triggerTask, periodicTrigger) : new ScheduledTasksEndpoint.FixedDelayTaskDescription(triggerTask, periodicTrigger));
} else {
return null;
}
}
It would be great if there were a mechanism for custom SchedulingConfigurer's to show up in the endpoint, but since there isn't one yet, the endpoint should perhaps just ignore them rather than throwing an exception.
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug