Skip to content

Update documentation to reflect the web server now being started immediately before the ContextRefreshedEvent is published #22277

@ykalemi

Description

@ykalemi

There are some behavior changes in Spring Boot 2.3.0. This issue #21325 commit introduced new Web Server lifecycle logic - WebServerStartStopLifecycle. And now there is this order during an applicaton startup:

  1. WebServerStartStopLifecycle.start -> webServer.start
  2. publishEvent(new ContextRefreshedEvent(this));

In Spring Boot 2.2.0 there was another logic (ServletWebServerApplicationContext.java):

protected void finishRefresh() {
    super.finishRefresh();
    WebServer webServer = startWebServer();
    if (webServer != null) {
        publishEvent(new ServletWebServerInitializedEvent(webServer, this));
    }
}

And order was like this:

  1. publishEvent(new ContextRefreshedEvent(this));
  2. webServer.start

We run some logic after the Spring context has been initialized but before web server started. With Spring Boot 2.3.0 web server processes requests before this logic is done.

If it is an expected change of events order, it should be mentioned in migration guide.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions