From 805e8af8d50258380468dc50eaaa64ebbfd3a931 Mon Sep 17 00:00:00 2001 From: Ares Date: Mon, 27 Apr 2026 15:18:20 +0800 Subject: [PATCH 1/2] Keep milliseconds precision in ThreadPoolTaskScheduleBuilder This commit fixes ThreadPoolTaskExecutorBuilder#awaitTerminationPeriod so that it does not lose millisecond precision. See gh-50225 Signed-off-by: Ares --- .../boot/task/ThreadPoolTaskSchedulerBuilder.java | 2 +- .../boot/task/ThreadPoolTaskSchedulerBuilderTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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..de44c43fdf8 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).asInt(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()); } From 08c94440fd96bfaaa0a5cd8b50111cb4211e8a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 28 Apr 2026 13:49:59 +0200 Subject: [PATCH 2/2] Polish "Keep milliseconds precision in ThreadPoolTaskScheduleBuilder" See gh-50225 --- .../boot/task/ThreadPoolTaskSchedulerBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 de44c43fdf8..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::toMillis).to(taskScheduler::setAwaitTerminationMillis); + 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)) {