Skip to content

Commit 76ad197

Browse files
committed
Deallocate servlet after forcing initialization in mappings endpoint
Previously, when using Tomcat, a call to mappings endpoint would force the initialization of any DispatcherServlets in the context. This was done by calling allocate on Tomcat's StandardWrapper. This left the wrapper in a state that would cause it to block for two seconds during shutdown as the wrapper has an outstanding allocation. This commit immediately deallocates the servlet after it has been allocated. This ensures that the DispatcherServlet has been initialized while also leaving the wrapper in a state that it can shut down immediately when asked to do so. Closes gh-14898
1 parent 9b8ead8 commit 76ad197

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ private void initializeServlet(Context context, String name) {
109109
Container child = context.findChild(name);
110110
if (child instanceof StandardWrapper) {
111111
try {
112-
((StandardWrapper) child).allocate();
112+
StandardWrapper wrapper = (StandardWrapper) child;
113+
wrapper.deallocate(wrapper.allocate());
113114
}
114115
catch (ServletException ex) {
115116
// Continue

0 commit comments

Comments
 (0)