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 <ares333@users.noreply.github.com>
This commit is contained in:
Ares
2026-04-28 13:46:08 +02:00
committed by Stéphane Nicoll
parent 37186284e4
commit 805e8af8d5
2 changed files with 2 additions and 2 deletions
@@ -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)) {
@@ -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());
}