throw ISE if WebSocketSCI.configure() is called on started ServletContextHandler

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-10-08 09:16:59 +11:00 committed by Joakim Erdfelt
parent 5e60837822
commit dc74bcf4cc
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 6 additions and 0 deletions

View File

@ -99,6 +99,9 @@ public class JavaxWebSocketServletContainerInitializer implements ServletContain
*/
public static void configure(ServletContextHandler context, Configurator configurator)
{
if (context.isStarted())
throw new IllegalStateException("configure should be called before starting");
// In this embedded-jetty usage, allow ServletContext.addListener() to
// add other ServletContextListeners (such as the ContextDestroyListener) after
// the initialization phase is over. (important for this SCI to function)

View File

@ -53,6 +53,9 @@ public class JettyWebSocketServletContainerInitializer implements ServletContain
*/
public static void configure(ServletContextHandler context, Configurator configurator)
{
if (context.isStarted())
throw new IllegalStateException("configure should be called before starting");
context.addEventListener(
ContainerInitializer
.asContextListener(new JettyWebSocketServletContainerInitializer())