Description
Use case: We would like to add some logic that runs on shutdown, but before the web server is shut down. To do so, we want to implement a SmartLifecycle
with a phase that’s higher than WebServerGracefulShutdownLifecycle
’s.
Our concrete use case is that we want to have the application wait some time before actually shutting down, as in #20995. However, the proposed solution in #20995 relies on hanging the thread that sends out the context closed event. We think that using the SmartLifecycle
interface is more appropriate. However, since WebServerGracefulShutdownLifecycle
’s phase is hard-coded to Integer.MAX_VALUE
, we can’t do that.
Proposal: Add a property server.shutdown-phase
to configure the SmartLifecycle
phase of all WebServerGracefulShutdownLifecycle
s. Default the value to Integer.MAX_VALUE
.
Alternative: Set the hard-coded phase of WebServerGracefulShutdownLifecycle
to something lower than Integer.MAX_VALUE
to allow using a higher phase. This is slightly less work, but is not strictly backwards-compatible, as it may influence the order in relation to other SmartLifecycle
s.
We would be happy to provide a pull request if one of the proposals is accepted.