Merge branch '2.1.x'

Closes gh-17928
pull/17939/head
Andy Wilkinson 5 years ago
commit 87339405f3

@ -71,8 +71,7 @@ class TomcatEmbeddedContext extends StandardContext {
Wrapper wrapper = (Wrapper) child; Wrapper wrapper = (Wrapper) child;
int order = wrapper.getLoadOnStartup(); int order = wrapper.getLoadOnStartup();
if (order >= 0) { if (order >= 0) {
grouped.computeIfAbsent(order, ArrayList::new); grouped.computeIfAbsent(order, (o) -> new ArrayList<>()).add(wrapper);
grouped.get(order).add(wrapper);
} }
} }
return grouped.values().stream().flatMap(List::stream); return grouped.values().stream().flatMap(List::stream);

@ -540,6 +540,21 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
() -> factory.getWebServer((context) -> context.addListener(new FailingServletContextListener()))); () -> factory.getWebServer((context) -> context.addListener(new FailingServletContextListener())));
} }
@Test
public void registerJspServletWithDefaultLoadOnStartup() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
factory.addInitializers(new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addServlet("manually-registered-jsp-servlet", JspServlet.class);
}
});
this.webServer = factory.getWebServer();
this.webServer.start();
}
@Override @Override
protected JspServlet getJspServlet() throws ServletException { protected JspServlet getJspServlet() throws ServletException {
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat(); Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();

Loading…
Cancel
Save