Do not restart contexts if pausing is disabled

If the PauseMode is set to NEVER, we never pause contexts and therefore
do not need to restart them.

See gh-36117
This commit is contained in:
Sam Brannen
2026-01-12 12:23:48 +01:00
parent ee4780fab6
commit 19c2506476
@@ -172,13 +172,15 @@ public class DefaultContextCache implements ContextCache {
}
private void restartContextIfNecessary(ApplicationContext context) {
// Recurse up the context hierarchy first.
ApplicationContext parent = context.getParent();
if (parent != null) {
restartContextIfNecessary(parent);
}
if (context instanceof ConfigurableApplicationContext cac && !cac.isRunning()) {
cac.restart();
if (this.pauseMode != PauseMode.NEVER) {
// Recurse up the context hierarchy first.
ApplicationContext parent = context.getParent();
if (parent != null) {
restartContextIfNecessary(parent);
}
if (context instanceof ConfigurableApplicationContext cac && !cac.isRunning()) {
cac.restart();
}
}
}