mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +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();
|
List<Connector> connectors = getConnectors();
|
||||||
connectors.forEach(this::close);
|
connectors.forEach(this::close);
|
||||||
shutdownUnderway.countDown();
|
shutdownUnderway.countDown();
|
||||||
try {
|
awaitInactiveOrAborted();
|
||||||
for (Container host : this.tomcat.getEngine().findChildren()) {
|
if (this.aborted) {
|
||||||
for (Container context : host.findChildren()) {
|
logger.info("Graceful shutdown aborted with one or more requests still active");
|
||||||
while (!this.aborted && isActive(context)) {
|
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
|
||||||
Thread.sleep(50);
|
|
||||||
}
|
|
||||||
if (this.aborted) {
|
|
||||||
logger.info("Graceful shutdown aborted with one or more requests still active");
|
|
||||||
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (InterruptedException ex) {
|
else {
|
||||||
Thread.currentThread().interrupt();
|
logger.info("Graceful shutdown complete");
|
||||||
|
callback.shutdownComplete(GracefulShutdownResult.IDLE);
|
||||||
}
|
}
|
||||||
logger.info("Graceful shutdown complete");
|
|
||||||
callback.shutdownComplete(GracefulShutdownResult.IDLE);
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
shutdownUnderway.countDown();
|
shutdownUnderway.countDown();
|
||||||
@ -105,6 +95,22 @@ final class GracefulShutdown {
|
|||||||
connector.getProtocolHandler().closeServerSocketGraceful();
|
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) {
|
private boolean isActive(Container context) {
|
||||||
try {
|
try {
|
||||||
if (((StandardContext) context).getInProgressAsyncCount() > 0) {
|
if (((StandardContext) context).getInProgressAsyncCount() > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user