Space out smart lifecycle phases used for graceful shutdown
Previously, the web server was stopped in the last smart lifecycle phase with graceful shutdown having begun in the previous phase. This lack of space between the two phases and after the stop phase made it hard to for other smart lifecycles to be part of the graceful shutdown process. This commit moves stop to 1024 phases before the final phase and graceful shutdown a further 1024 phases before that, allowing other smart lifecycles to run between graceful shutdown and stop and also after stop. Closes gh-31714
This commit is contained in:
parent
68e4aa232b
commit
f2f4a4a40e
|
@ -31,7 +31,7 @@ public final class WebServerGracefulShutdownLifecycle implements SmartLifecycle
|
|||
* {@link SmartLifecycle#getPhase() SmartLifecycle phase} in which graceful shutdown
|
||||
* of the web server is performed.
|
||||
*/
|
||||
public static final int SMART_LIFECYCLE_PHASE = SmartLifecycle.DEFAULT_PHASE;
|
||||
public static final int SMART_LIFECYCLE_PHASE = SmartLifecycle.DEFAULT_PHASE - 1024;
|
||||
|
||||
private final WebServer webServer;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.web.reactive.context;
|
||||
|
||||
import org.springframework.boot.web.context.WebServerGracefulShutdownLifecycle;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
||||
|
@ -54,7 +55,7 @@ class WebServerStartStopLifecycle implements SmartLifecycle {
|
|||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return Integer.MAX_VALUE - 1;
|
||||
return WebServerGracefulShutdownLifecycle.SMART_LIFECYCLE_PHASE - 1024;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.web.servlet.context;
|
||||
|
||||
import org.springframework.boot.web.context.WebServerGracefulShutdownLifecycle;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
||||
|
@ -59,7 +60,7 @@ class WebServerStartStopLifecycle implements SmartLifecycle {
|
|||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return Integer.MAX_VALUE - 1;
|
||||
return WebServerGracefulShutdownLifecycle.SMART_LIFECYCLE_PHASE - 1024;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue