only allow adding ServletContainerInitializers before starting

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-01-21 15:27:15 +11:00
parent c6c1ccfdd0
commit ff4f2ef28f
1 changed files with 6 additions and 0 deletions

View File

@ -703,6 +703,9 @@ public class ServletContextHandler extends ContextHandler
*/
public void addServletContainerInitializer(ServletContainerInitializer containerInitializer)
{
if (!isStopped())
throw new IllegalStateException("ServletContainerInitializers should be added before starting");
addServletContainerInitializer(containerInitializer, Collections.emptySet());
}
@ -714,6 +717,9 @@ public class ServletContextHandler extends ContextHandler
*/
public void addServletContainerInitializer(ServletContainerInitializer containerInitializer, Set<Class<?>> classes)
{
if (!isStopped())
throw new IllegalStateException("ServletContainerInitializers should be added before starting");
addManaged(new Initializer(this, containerInitializer, classes));
}