-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Following up on #35171 and #35168, there are scenarios where a hard Lifecycle.stop()
call on context pausing is undesirable, for example with ephemeral ports. This can currently be worked around through an early opt-out in the custom stop()
implementation (see #35168 (comment)) but would benefit from a more obvious arrangement, also allowing for existing stop()
behavior to remain as-is.
As a consequence, we're introducing a SmartLifecycle.isPauseable()
method which defaults to true
but can be switched to false
based on certain configuration state in the component, or even always returning false
for never participating in a pause attempt. The Test Context Framework calls ConfigurableApplicationContext.pause()
now which takes isPauseable()
into account, and ConfigurableApplicationContext.restart()
also just stops pauseable components (if not paused yet) for its restart attempt.