diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilder.java index 8b7852ba798..07e72d3cdc3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilder.java @@ -228,7 +228,7 @@ public class ThreadPoolTaskSchedulerBuilder { PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(this.poolSize).to(taskScheduler::setPoolSize); map.from(this.awaitTermination).to(taskScheduler::setWaitForTasksToCompleteOnShutdown); - map.from(this.awaitTerminationPeriod).asInt(Duration::getSeconds).to(taskScheduler::setAwaitTerminationSeconds); + map.from(this.awaitTerminationPeriod).as(Duration::toMillis).to(taskScheduler::setAwaitTerminationMillis); map.from(this.threadNamePrefix).to(taskScheduler::setThreadNamePrefix); map.from(this.taskDecorator).to(taskScheduler::setTaskDecorator); if (!CollectionUtils.isEmpty(this.customizers)) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilderTests.java index 35b5bf82a75..8a71b364ae3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/ThreadPoolTaskSchedulerBuilderTests.java @@ -54,7 +54,7 @@ class ThreadPoolTaskSchedulerBuilderTests { @Test void awaitTerminationPeriodShouldApply() { - Duration period = Duration.ofMinutes(1); + Duration period = Duration.ofMillis(50); ThreadPoolTaskScheduler executor = this.builder.awaitTerminationPeriod(period).build(); assertThat(executor).hasFieldOrPropertyWithValue("awaitTerminationMillis", period.toMillis()); }