Skip to content

Declare a public constant for the WebServerStartStopLifecycle's phase #45572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SmokeIT opened this issue May 15, 2025 · 2 comments
Open

Declare a public constant for the WebServerStartStopLifecycle's phase #45572

SmokeIT opened this issue May 15, 2025 · 2 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@SmokeIT
Copy link

SmokeIT commented May 15, 2025

The (servlet and reactive) WebServerStartStopLifecycle.getPhase() method is currently hardcoded as:

@Override
public int getPhase() {
    return WebServerGracefulShutdownLifecycle.SMART_LIFECYCLE_PHASE - 1024;
}

It would be nice if this phase was declared as a public constant. This would make it easier to start a custom SmartLifecycle before an application starts accepting HTTP requests.

Currently we declare our own constant for this, but there is no guarantee the WebServerStartStopLifecycle phase will never change.

It is also not possible to depend on the webServerStartStop bean in order to obtain its phase, since dependency relationships take precedence over phases. That is, if Bean A depends on the webServerStartStop bean, it will be started after the webServerStartStop bean, regardless of Bean A's phase.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 15, 2025
@philwebb
Copy link
Member

WebServerStartStopLifecycle is a package-private class so adding a constant there won't help. Perhaps we could add something to ServletWebServerApplicationContext?

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label May 15, 2025
@wilkinsona
Copy link
Member

There's the reactive side of things as well so I don't think it should be added to ServletWebServerApplicationContext . Perhaps WebServerApplicationContext though? The constant for the graceful shutdown phase could move there too.

@philwebb philwebb added type: enhancement A general enhancement and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels May 16, 2025
@philwebb philwebb added this to the 4.0.x milestone May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants