-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Graceful shutdown for @Scheduled tasks quits instantly #30556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is the standard behaviour of Framework's scheduling support. When |
But what's the sense of So how could I then delay the shutdown if a |
They aren't destroyed. As I said above, an attempt is made to interrupt the task. That's all.
If the task ignores the thread being interrupted, it will continue running. Here's an example:
The app will now wait for 30 seconds for the task to complete:
If you would like |
Thanks for the insight. I changed the test method as follows, then the shutdown is delayed correctly:
|
Yes. If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. |
The solution given, where we can add the following... try {
...
} catch (InterruptedException ex) {
// Reset interrupt flag and keep going
Thread.currentThread().interrupt();
} ... to code that throws those exceptions does not work. Sending SIGTERM still causes the application to close before thead pool tasks have finished running. |
any changes? it seem spring project define it bug and fix it though |
The following configuration shuts down instantly when the application is stopped.
If I'm not missing any configuration, this might be a bug?
application.properties
:spring-boot-2.6.6
withspring-boot-starter-web
dependency.The text was updated successfully, but these errors were encountered: