Adapt to deprecations in Framework's scheduling APIs
See gh-31241
This commit is contained in:
@@ -168,14 +168,14 @@ public class ScheduledTasksEndpoint {
|
||||
|
||||
protected IntervalTaskDescription(TaskType type, IntervalTask task) {
|
||||
super(type, task.getRunnable());
|
||||
this.initialDelay = task.getInitialDelay();
|
||||
this.interval = task.getInterval();
|
||||
this.initialDelay = task.getInitialDelayDuration().toMillis();
|
||||
this.interval = task.getIntervalDuration().toMillis();
|
||||
}
|
||||
|
||||
protected IntervalTaskDescription(TaskType type, TriggerTask task, PeriodicTrigger trigger) {
|
||||
super(type, task.getRunnable());
|
||||
this.initialDelay = trigger.getInitialDelay();
|
||||
this.interval = trigger.getPeriod();
|
||||
this.initialDelay = trigger.getInitialDelayDuration().toMillis();
|
||||
this.interval = trigger.getPeriodDuration().toMillis();
|
||||
}
|
||||
|
||||
public long getInitialDelay() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.boot.actuate.scheduling;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -196,8 +196,8 @@ class ScheduledTasksEndpointTests {
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(1, TimeUnit.SECONDS);
|
||||
trigger.setInitialDelay(2);
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofSeconds(1));
|
||||
trigger.setInitialDelay(Duration.ofSeconds(2));
|
||||
taskRegistrar.addTriggerTask(new FixedDelayTriggerRunnable(), trigger);
|
||||
}
|
||||
|
||||
@@ -207,8 +207,8 @@ class ScheduledTasksEndpointTests {
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(2, TimeUnit.SECONDS);
|
||||
trigger.setInitialDelay(3);
|
||||
PeriodicTrigger trigger = new PeriodicTrigger(Duration.ofSeconds(2));
|
||||
trigger.setInitialDelay(Duration.ofSeconds(3));
|
||||
trigger.setFixedRate(true);
|
||||
taskRegistrar.addTriggerTask(new FixedRateTriggerRunnable(), trigger);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ class ScheduledTasksEndpointTests {
|
||||
|
||||
static class CustomTriggerTask implements SchedulingConfigurer {
|
||||
|
||||
private static final Trigger trigger = (context) -> new Date();
|
||||
private static final Trigger trigger = (context) -> Instant.now();
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
|
||||
Reference in New Issue
Block a user