From 76ad1975844550609ff58caa0ce6255be15a9cb7 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 19 Oct 2018 10:43:23 +0100 Subject: [PATCH] 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 --- .../web/mappings/servlet/DispatcherServletHandlerMappings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java index d2afc78f34..377c504fff 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java @@ -109,7 +109,8 @@ final class DispatcherServletHandlerMappings { Container child = context.findChild(name); if (child instanceof StandardWrapper) { try { - ((StandardWrapper) child).allocate(); + StandardWrapper wrapper = (StandardWrapper) child; + wrapper.deallocate(wrapper.allocate()); } catch (ServletException ex) { // Continue