Skip to content
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

WebServer is not destroyed when ReactiveWebServerApplicationContext refresh fails #44134

Closed
wants to merge 1 commit into from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Feb 5, 2025

Prior to this commit, if ReactiveWebServerApplicationContext failed to refresh, only WebServer.stop() was called.

This commit additionally invokes WebServer.destroy(), aligning the behaviour with ServletWebServerApplicationContext when a refresh failure occurs.

gh-44101

I am also thinking about these changes as well:

3.3.x...nosan:spring-boot:44100-1

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 5, 2025
WebServer webServer = getWebServer();
if (webServer != null) {
webServer.stop();
webServer.destroy();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it make sense to destroy webServer even if stop() throws an exception?

Probably out of the scope for this fix, but it looks like Juergen was thinking about calling destroy() method in context of a bean lifecycle: #34955 (comment)

Thank you for the quick action in regard #44101! 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think so. If stop() throws an exception, it likely means that some resources, such as files, networks, etc. are still in use, which could cause destroy() to fail as well.

@nosan
Copy link
Contributor Author

nosan commented Feb 6, 2025

An alternative approach is 3.3.x...nosan:spring-boot:44101-alternative, which always tries to stop and destroy WebServer in case of a refresh failure or during ApplicationContext.close().

}
}
catch (Exception shutdownEx) {
ex.addSuppressed(shutdownEx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's consider this separately please. If we do it, it should be applied on the servlet side as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've reverted these changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We think that adding the stop or destroy failure as a suppressed exception is a good idea. Would you like to open a PR for it or would you prefer that we take care of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wilkinsona wilkinsona changed the title Destroy WebServer if ReactiveWebServerApplicationContext refresh fails WebServer is not destroyed when ReactiveWebServerApplicationContext refresh fails Feb 13, 2025
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 13, 2025
@wilkinsona wilkinsona added this to the 3.3.x milestone Feb 13, 2025
@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Feb 13, 2025
Prior to this commit, if ReactiveWebServerApplicationContext failed to
refresh, only WebServer.stop() was called.

This commit additionally invokes WebServer.destroy(), aligning
the behavior with ServletWebServerApplicationContext when a refresh
failure occurs.

Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Feb 17, 2025
@snicoll snicoll modified the milestones: 3.3.x, 3.3.9 Feb 17, 2025
@snicoll snicoll self-assigned this Feb 17, 2025
snicoll pushed a commit that referenced this pull request Feb 17, 2025
Prior to this commit, if ReactiveWebServerApplicationContext failed to
refresh, only WebServer.stop() was called.

This commit additionally invokes WebServer.destroy(), aligning
the behavior with ServletWebServerApplicationContext when a refresh
failure occurs.

See gh-44134

Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
@snicoll snicoll closed this in 6f05926 Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants