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
pull/14914/head
Andy Wilkinson 6 years ago
parent 9b8ead825c
commit 76ad197584

@ -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

Loading…
Cancel
Save