mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Merge branch '3.1.x' into 3.2.x
While the bug fixed in 3.1.x (gh-39942) has already been addressed as
a side-effect of the changes made in dbb24286
, the change is merged
forwards here to improve the consistency of the code between branches.
This commit is contained in:
commit
f2ddf1c082
@ -67,25 +67,15 @@ final class GracefulShutdown {
|
||||
List<Connector> connectors = getConnectors();
|
||||
connectors.forEach(this::close);
|
||||
shutdownUnderway.countDown();
|
||||
try {
|
||||
for (Container host : this.tomcat.getEngine().findChildren()) {
|
||||
for (Container context : host.findChildren()) {
|
||||
while (!this.aborted && isActive(context)) {
|
||||
Thread.sleep(50);
|
||||
}
|
||||
if (this.aborted) {
|
||||
logger.info("Graceful shutdown aborted with one or more requests still active");
|
||||
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
awaitInactiveOrAborted();
|
||||
if (this.aborted) {
|
||||
logger.info("Graceful shutdown aborted with one or more requests still active");
|
||||
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
else {
|
||||
logger.info("Graceful shutdown complete");
|
||||
callback.shutdownComplete(GracefulShutdownResult.IDLE);
|
||||
}
|
||||
logger.info("Graceful shutdown complete");
|
||||
callback.shutdownComplete(GracefulShutdownResult.IDLE);
|
||||
}
|
||||
finally {
|
||||
shutdownUnderway.countDown();
|
||||
@ -105,6 +95,22 @@ final class GracefulShutdown {
|
||||
connector.getProtocolHandler().closeServerSocketGraceful();
|
||||
}
|
||||
|
||||
private void awaitInactiveOrAborted() {
|
||||
try {
|
||||
for (Container host : this.tomcat.getEngine().findChildren()) {
|
||||
for (Container context : host.findChildren()) {
|
||||
while (!this.aborted && isActive(context)) {
|
||||
Thread.sleep(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isActive(Container context) {
|
||||
try {
|
||||
if (((StandardContext) context).getInProgressAsyncCount() > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user