spring-projects / spring-projects/spring-boot

Rename spring.task.execution.shutdown.await-termination to align with setWaitForTasksToCompleteOnShutdown

Open
#30,557 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: pending-design-work type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

spring-boot-2.6.6

I want my @Async tasks to delay a shutdown.

application.properties:

server.shutdown=graceful
server.shutdown.grace-period=30s
spring.task.execution.shutdown.await-termination=true
@SpringBootApplication
@EnableAsync
public class AppConfiguration {
	public static void main(String[] args) {
		SpringApplication.run(AppConfiguration.class, args);
	}
}

@Service
public class AsyncService {
	private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

	@Async
	void runAsync() throws InterruptedException {
		LOGGER.info("Starting async job...");
		TimeUnit.MINUTES.sleep(5);
		LOGGER.info("Async job finished.");
	}
}

@RestController
public class MyController {
	@Autowired(required = false)
	private AsyncService async;

	@GetMapping("/async")
	public String async() throws InterruptedException {
                LOGGER.info("Async servlet accessed");
		async.runAsync();
		return "Async process started in background. Please shut down the application now!";
	}
}

-webflux:

2022-04-06 13:24:16.976  INFO 267878 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2022-04-06 13:24:16.986  INFO 267878 --- [           main] AppConfiguration     : Started AppConfiguration in 0.801 seconds (JVM running for 1.076)
2022-04-06 13:24:30.666  INFO 267878 --- [or-http-epoll-2] HelloServlet         : Async servlet accessed
2022-04-06 13:24:30.668  INFO 267878 --- [         task-1] AsyncService         : Starting async job...
Disconnected from the target VM, address: '127.0.0.1:36143', transport: 'socket'
2022-04-06 13:24:34.429  INFO 267878 --- [ionShutdownHook] o.s.b.w.embedded.netty.GracefulShutdown  : Commencing graceful shutdown. Waiting for active requests to complete
2022-04-06 13:24:34.431  INFO 267878 --- [ netty-shutdown] o.s.b.w.embedded.netty.GracefulShutdown  : Graceful shutdown complete

Process finished with exit code 130 (interrupted by signal 2: SIGINT)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the application.properties example and the @Async reproduction as entry points. Locate the Spring Boot task-execution shutdown property definition and its tests, then verify the renamed property aligns with setWaitForTasksToCompleteOnShutdown while preserving delayed shutdown behavior. Done means the naming is updated and the async shutdown scenario is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.