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 https://github.com/spring-projects/spring-framework/issues/35168#issuecomment-3126864639) 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.