Skip to content

Introduce ConfigurableApplicationContext.pause() and SmartLifecycle.isPauseable() #35269

@jhoeller

Description

@jhoeller

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions