Skip to content

Commit 38d7275

Browse files
committed
Upgrade to Tomcat 10.1.19
Closes gh-39730
1 parent 14ed152 commit 38d7275

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ kotlinVersion=1.9.22
1313
mavenVersion=3.9.4
1414
nativeBuildToolsVersion=0.10.1
1515
springFrameworkVersion=6.1.4
16-
tomcatVersion=10.1.18
16+
tomcatVersion=10.1.19
1717

1818
kotlin.stdlib.default.dependency=false

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/GracefulShutdown.java

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.Collections;
2121
import java.util.List;
22+
import java.util.concurrent.CountDownLatch;
2223

2324
import org.apache.catalina.Container;
2425
import org.apache.catalina.Service;
@@ -51,32 +52,44 @@ final class GracefulShutdown {
5152

5253
void shutDownGracefully(GracefulShutdownCallback callback) {
5354
logger.info("Commencing graceful shutdown. Waiting for active requests to complete");
54-
new Thread(() -> doShutdown(callback), "tomcat-shutdown").start();
55+
CountDownLatch shutdownUnderway = new CountDownLatch(1);
56+
new Thread(() -> doShutdown(callback, shutdownUnderway), "tomcat-shutdown").start();
57+
try {
58+
shutdownUnderway.await();
59+
}
60+
catch (InterruptedException ex) {
61+
Thread.currentThread().interrupt();
62+
}
5563
}
5664

57-
private void doShutdown(GracefulShutdownCallback callback) {
58-
List<Connector> connectors = getConnectors();
59-
connectors.forEach(this::close);
65+
private void doShutdown(GracefulShutdownCallback callback, CountDownLatch shutdownUnderway) {
6066
try {
61-
for (Container host : this.tomcat.getEngine().findChildren()) {
62-
for (Container context : host.findChildren()) {
63-
while (!this.aborted && isActive(context)) {
64-
Thread.sleep(50);
65-
}
66-
if (this.aborted) {
67-
logger.info("Graceful shutdown aborted with one or more requests still active");
68-
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
69-
return;
67+
List<Connector> connectors = getConnectors();
68+
connectors.forEach(this::close);
69+
shutdownUnderway.countDown();
70+
try {
71+
for (Container host : this.tomcat.getEngine().findChildren()) {
72+
for (Container context : host.findChildren()) {
73+
while (!this.aborted && isActive(context)) {
74+
Thread.sleep(50);
75+
}
76+
if (this.aborted) {
77+
logger.info("Graceful shutdown aborted with one or more requests still active");
78+
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
79+
return;
80+
}
7081
}
7182
}
7283
}
73-
84+
catch (InterruptedException ex) {
85+
Thread.currentThread().interrupt();
86+
}
87+
logger.info("Graceful shutdown complete");
88+
callback.shutdownComplete(GracefulShutdownResult.IDLE);
7489
}
75-
catch (InterruptedException ex) {
76-
Thread.currentThread().interrupt();
90+
finally {
91+
shutdownUnderway.countDown();
7792
}
78-
logger.info("Graceful shutdown complete");
79-
callback.shutdownComplete(GracefulShutdownResult.IDLE);
8093
}
8194

8295
private List<Connector> getConnectors() {

0 commit comments

Comments
 (0)