Skip to content

Commit f4afd07

Browse files
committed
Merge pull request #22604 from ttddyy
* gh-22604: Polish "Use milliseconds when configuring awaitTerminationPeriod" Use milliseconds when configuring awaitTerminationPeriod Closes gh-22604
2 parents d9b61c4 + ea5284c commit f4afd07

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -308,7 +308,7 @@ public <T extends ThreadPoolTaskExecutor> T configure(T taskExecutor) {
308308
map.from(this.keepAlive).asInt(Duration::getSeconds).to(taskExecutor::setKeepAliveSeconds);
309309
map.from(this.allowCoreThreadTimeOut).to(taskExecutor::setAllowCoreThreadTimeOut);
310310
map.from(this.awaitTermination).to(taskExecutor::setWaitForTasksToCompleteOnShutdown);
311-
map.from(this.awaitTerminationPeriod).asInt(Duration::getSeconds).to(taskExecutor::setAwaitTerminationSeconds);
311+
map.from(this.awaitTerminationPeriod).as(Duration::toMillis).to(taskExecutor::setAwaitTerminationMillis);
312312
map.from(this.threadNamePrefix).whenHasText().to(taskExecutor::setThreadNamePrefix);
313313
map.from(this.taskDecorator).to(taskExecutor::setTaskDecorator);
314314
if (!CollectionUtils.isEmpty(this.customizers)) {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ void awaitTerminationShouldApply() {
6161
}
6262

6363
@Test
64-
void awaitTerminationPeriodShouldApply() {
65-
Duration period = Duration.ofMinutes(1);
64+
void awaitTerminationPeriodShouldApplyWithMillisecondPrecision() {
65+
Duration period = Duration.ofMillis(50);
6666
ThreadPoolTaskExecutor executor = this.builder.awaitTerminationPeriod(period).build();
6767
assertThat(executor).hasFieldOrPropertyWithValue("awaitTerminationMillis", period.toMillis());
6868
}

0 commit comments

Comments
 (0)